use of com.sun.management.VMOption in project LinkAgent by shulieTech.
the class VMOptionModule method info.
@Command(value = "info", description = "查看虚拟机参数")
public CommandResponse info(final Map<String, String> args) {
String name = args.get("name");
try {
HotSpotDiagnosticMXBean hotSpotDiagnosticMXBean = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
if (StringUtils.isBlank(name)) {
// show all options
final List<VMOption> diagnosticOptions = hotSpotDiagnosticMXBean.getDiagnosticOptions();
List<VmOption> vmOptions = new ArrayList<VmOption>();
for (VMOption vmOption : diagnosticOptions) {
vmOptions.add(new VmOption(vmOption));
}
return CommandResponse.success(vmOptions);
} else {
// view the specified option
VMOption option = hotSpotDiagnosticMXBean.getVMOption(name);
if (option == null) {
return CommandResponse.failure("In order to change the system properties, you must specify the property value.");
} else {
List<VmOption> vmOptions = new ArrayList<VmOption>();
vmOptions.add(new VmOption(option));
return CommandResponse.success(vmOptions);
}
}
} catch (Throwable t) {
return CommandResponse.failure(t);
}
}
use of com.sun.management.VMOption in project LinkAgent by shulieTech.
the class VMOptionModule method setOption.
@Command(value = "setOption", description = "设置虚拟机参数")
public CommandResponse setOption(final Map<String, String> args) {
String name = args.get("name");
String value = args.get("value");
try {
HotSpotDiagnosticMXBean hotSpotDiagnosticMXBean = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
VMOption vmOption = hotSpotDiagnosticMXBean.getVMOption(name);
String originValue = vmOption.getValue();
// change vm option
hotSpotDiagnosticMXBean.setVMOption(name, value);
return CommandResponse.success(true);
} catch (Throwable t) {
return CommandResponse.failure(t);
}
}
use of com.sun.management.VMOption in project jbang-catalog by quintesse.
the class jvmci method main.
public static void main(String[] args) {
// Am I running on a JDK that supports JVMCI?
String vm_version = System.getProperty("java.vm.version");
System.out.printf("java.vm.version = %s%n", vm_version);
HotSpotDiagnosticMXBean bean = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
// Is JVMCI enabled?
VMOption enableJVMCI = bean.getVMOption("EnableJVMCI");
System.out.println(enableJVMCI);
// Is the system using the JVMCI compiler for normal compilations?
VMOption useJVMCICompiler = bean.getVMOption("UseJVMCICompiler");
System.out.println(useJVMCICompiler);
// What compiler is selected?
String compiler = System.getProperty("jvmci.Compiler");
System.out.printf("jvmci.Compiler = %s%n", compiler);
}
use of com.sun.management.VMOption in project xap by xap.
the class HotSpotDiagnosticWrapper method useCompressedOopsAsBoolean.
@Override
public boolean useCompressedOopsAsBoolean() {
VMOption vmOption = getVMOption("UseCompressedOops");
String val = vmOption != null ? vmOption.getValue() : null;
return Boolean.parseBoolean(val);
}
Aggregations