本文整理汇总了Java中sun.management.ManagementFactoryHelper.getCompilationMXBean方法的典型用法代码示例。如果您正苦于以下问题:Java ManagementFactoryHelper.getCompilationMXBean方法的具体用法?Java ManagementFactoryHelper.getCompilationMXBean怎么用?Java ManagementFactoryHelper.getCompilationMXBean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.management.ManagementFactoryHelper
的用法示例。
在下文中一共展示了ManagementFactoryHelper.getCompilationMXBean方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runTest
import sun.management.ManagementFactoryHelper; //导入方法依赖的package包/类
/**
* Template method for testing. Prints tested method's info before
* {@linkplain #test()} and after {@linkplain #test()} or on thrown
* exception.
*
* @throws RuntimeException if method {@linkplain #test()} throws any
* exception
* @see #test()
*/
protected final void runTest() {
if (ManagementFactoryHelper.getCompilationMXBean() == null) {
System.err.println(
"Warning: test is not applicable in interpreted mode");
return;
}
System.out.println("at test's start:");
printInfo();
try {
test();
} catch (Exception e) {
System.out.printf("on exception '%s':", e.getMessage());
printInfo();
e.printStackTrace();
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
throw new RuntimeException(e);
}
System.out.println("at test's end:");
printInfo();
}
示例2: main
import sun.management.ManagementFactoryHelper; //导入方法依赖的package包/类
/**
* Entry point. Compiles classes in {@code args}, or all classes in
* boot-classpath if args is empty
*
* @param args paths to jar/zip, dir contains classes, or to .lst file
* contains list of classes to compile
*/
public static void main(String[] args) {
String logfile = Utils.LOG_FILE;
PrintStream os = null;
if (logfile != null) {
try {
os = new PrintStream(Files.newOutputStream(Paths.get(logfile)));
} catch (IOException io) {
}
}
if (os != null) {
System.setOut(os);
}
try {
try {
if (ManagementFactoryHelper.getCompilationMXBean() == null) {
throw new RuntimeException(
"CTW can not work in interpreted mode");
}
} catch (java.lang.NoClassDefFoundError e) {
// compact1, compact2 support
}
String[] paths = args;
boolean skipRtJar = false;
if (args.length == 0) {
paths = getDefaultPaths();
skipRtJar = true;
}
ExecutorService executor = createExecutor();
long start = System.currentTimeMillis();
try {
String path;
for (int i = 0, n = paths.length; i < n
&& !PathHandler.isFinished(); ++i) {
path = paths[i];
if (skipRtJar && i > 0 && isRtJar(path)) {
// rt.jar is not first, so skip it
continue;
}
PathHandler.create(path, executor).process();
}
} finally {
await(executor);
}
System.out.printf("Done (%d classes, %d methods, %d ms)%n",
Compiler.getClassCount(),
Compiler.getMethodCount(),
System.currentTimeMillis() - start);
} finally {
if (os != null) {
os.close();
}
}
}
示例3: getCompilationMXBean
import sun.management.ManagementFactoryHelper; //导入方法依赖的package包/类
/**
* Returns the managed bean for the compilation system of
* the Java virtual machine. This method returns <tt>null</tt>
* if the Java virtual machine has no compilation system.
*
* @return a {@link CompilationMXBean} object for the Java virtual
* machine or <tt>null</tt> if the Java virtual machine has
* no compilation system.
*/
public static CompilationMXBean getCompilationMXBean() {
return ManagementFactoryHelper.getCompilationMXBean();
}