本文整理汇总了Java中com.sun.management.HotSpotDiagnosticMXBean.getVMOption方法的典型用法代码示例。如果您正苦于以下问题:Java HotSpotDiagnosticMXBean.getVMOption方法的具体用法?Java HotSpotDiagnosticMXBean.getVMOption怎么用?Java HotSpotDiagnosticMXBean.getVMOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.management.HotSpotDiagnosticMXBean
的用法示例。
在下文中一共展示了HotSpotDiagnosticMXBean.getVMOption方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkVMOption
import com.sun.management.HotSpotDiagnosticMXBean; //导入方法依赖的package包/类
private static void checkVMOption(HotSpotDiagnosticMXBean mbean) {
VMOption option = mbean.getVMOption(PRINT_GC_DETAILS);
if (!option.getValue().equalsIgnoreCase(EXPECTED_VALUE)) {
throw new RuntimeException("Unexpected value: " +
option.getValue() + " expected: " + EXPECTED_VALUE);
}
boolean iae = false;
try {
mbean.getVMOption(BAD_OPTION);
} catch (IllegalArgumentException e) {
iae = true;
}
if (!iae) {
throw new RuntimeException("Invalid VM Option" +
" was not detected");
}
}
示例2: main
import com.sun.management.HotSpotDiagnosticMXBean; //导入方法依赖的package包/类
public static void main(String... args) throws Exception {
MBeanServerConnection msc = ManagementFactory.getPlatformMBeanServer();
HotSpotDiagnosticMXBean mxbean =
ManagementFactory.getPlatformMXBean(msc, HotSpotDiagnosticMXBean.class);
String[] signatures = new String[] {
String.class.getName()
};
Object obj = msc.invoke(mxbean.getObjectName(), "getVMOption",
new String[] { "PrintVMOptions"}, signatures);
CompositeData data = (CompositeData)obj;
validateType(data);
VMOption option = mxbean.getVMOption("PrintVMOptions");
VMOption o = VMOption.from(data);
assertEquals(option, o);
}
示例3: checkVMOption
import com.sun.management.HotSpotDiagnosticMXBean; //导入方法依赖的package包/类
private static void checkVMOption(HotSpotDiagnosticMXBean mbean) {
VMOption option = mbean.getVMOption(HEAP_DUMP_ON_OOM);
if (!option.getValue().equalsIgnoreCase(EXPECTED_VALUE)) {
throw new RuntimeException("Unexpected value: " +
option.getValue() + " expected: " + EXPECTED_VALUE);
}
boolean iae = false;
try {
mbean.getVMOption(BAD_OPTION);
} catch (IllegalArgumentException e) {
iae = true;
}
if (!iae) {
throw new RuntimeException("Invalid VM Option" +
" was not detected");
}
}
示例4: getVMOption
import com.sun.management.HotSpotDiagnosticMXBean; //导入方法依赖的package包/类
/**
* Returns value of VM option.
*
* @param name option's name
* @return value of option or {@code null}, if option doesn't exist
* @throws NullPointerException if name is null
*/
protected static String getVMOption(String name) {
Objects.requireNonNull(name);
HotSpotDiagnosticMXBean diagnostic
= ManagementFactoryHelper.getDiagnosticMXBean();
VMOption tmp;
try {
tmp = diagnostic.getVMOption(name);
} catch (IllegalArgumentException e) {
tmp = null;
}
return (tmp == null ? null : tmp.getValue());
}
示例5: getCompressedClassSpaceSize
import com.sun.management.HotSpotDiagnosticMXBean; //导入方法依赖的package包/类
private static long getCompressedClassSpaceSize() {
HotSpotDiagnosticMXBean diagnostic =
ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
VMOption option = diagnostic.getVMOption("CompressedClassSpaceSize");
return Long.parseLong(option.getValue());
}
示例6: checkVMOption
import com.sun.management.HotSpotDiagnosticMXBean; //导入方法依赖的package包/类
private static void checkVMOption(HotSpotDiagnosticMXBean mbean) {
VMOption option = mbean.getVMOption(COMPILE_THRESHOLD_SCALING);
if (!option.getValue().equalsIgnoreCase(EXPECTED_VALUE)) {
throw new RuntimeException("Unexpected value: " +
option.getValue() + " expected: " + EXPECTED_VALUE);
}
}
示例7: main
import com.sun.management.HotSpotDiagnosticMXBean; //导入方法依赖的package包/类
public static void main(String[] args) {
HotSpotDiagnosticMXBean hsd = ManagementFactoryHelper.getDiagnosticMXBean();
// 打印虚拟机的某个配置参数的值
VMOption vmo = hsd.getVMOption("UseCompressedOops");
System.out.println(vmo.getName() + " | " + vmo.getValue());
hsd.getDiagnosticOptions().stream().forEach(System.out::println);
}
示例8: testingG1GC
import com.sun.management.HotSpotDiagnosticMXBean; //导入方法依赖的package包/类
public static boolean testingG1GC() {
HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();
VMOption option = diagnostic.getVMOption("UseG1GC");
if (option.getValue().equals("false")) {
System.out.println("Skipping this test. It is only a G1 test.");
return false;
}
return true;
}
示例9: main
import com.sun.management.HotSpotDiagnosticMXBean; //导入方法依赖的package包/类
public static void main(String[] args) {
HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();
String expectedValue = getExpectedValue(args);
VMOption option = diagnostic.getVMOption("G1HeapRegionSize");
if (!expectedValue.equals(option.getValue())) {
throw new RuntimeException("Wrong value for G1HeapRegionSize. Expected " + expectedValue + " but got " + option.getValue());
}
}
示例10: main
import com.sun.management.HotSpotDiagnosticMXBean; //导入方法依赖的package包/类
public static void main(String[] args) {
HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();
VMOption option = diagnostic.getVMOption("UseG1GC");
if (option.getValue().equals("false")) {
System.out.println("Skipping this test. It is only a G1 test.");
return;
}
String expectedValue = getExpectedValue(args);
option = diagnostic.getVMOption("G1HeapRegionSize");
if (!expectedValue.equals(option.getValue())) {
throw new RuntimeException("Wrong value for G1HeapRegionSize. Expected " + expectedValue + " but got " + option.getValue());
}
}
示例11: getCompressedClassSpaceSize
import com.sun.management.HotSpotDiagnosticMXBean; //导入方法依赖的package包/类
private static long getCompressedClassSpaceSize() {
HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();
VMOption option = diagnostic.getVMOption("CompressedClassSpaceSize");
return Long.parseLong(option.getValue());
}