utils.java
来自「linux下建立JAVA虚拟机的源码KAFFE」· Java 代码 · 共 43 行
JAVA
43 行
package antlr;
public class Utils {
private static boolean useSystemExit = true;
private static boolean useDirectClassLoading = false;
static {
if ("true".equalsIgnoreCase(System.getProperty("ANTLR_DO_NOT_EXIT", "false")))
useSystemExit = false;
if ("true".equalsIgnoreCase(System.getProperty("ANTLR_USE_DIRECT_CLASS_LOADING", "false")))
useDirectClassLoading = true;
}
/** Thanks to Max Andersen at JBOSS and Scott Stanchfield */
public static Class loadClass(String name) throws ClassNotFoundException {
try {
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
if (!useDirectClassLoading && contextClassLoader!=null ) {
return contextClassLoader.loadClass(name);
}
return Class.forName(name);
}
catch (Exception e) {
return Class.forName(name);
}
}
public static Object createInstanceOf(String name) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
return loadClass(name).newInstance();
}
public static void error(String message) {
if (useSystemExit)
System.exit(1);
throw new RuntimeException("ANTLR Panic: " + message);
}
public static void error(String message, Throwable t) {
if (useSystemExit)
System.exit(1);
throw new RuntimeException("ANTLR Panic", t);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?