Search in sources :

Example 6 with VMOption

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);
    }
}
Also used : VmOption(com.shulie.instrument.simulator.module.model.vmoption.VmOption) HotSpotDiagnosticMXBean(com.sun.management.HotSpotDiagnosticMXBean) VMOption(com.sun.management.VMOption) ArrayList(java.util.ArrayList) Command(com.shulie.instrument.simulator.api.annotation.Command)

Example 7 with VMOption

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);
    }
}
Also used : HotSpotDiagnosticMXBean(com.sun.management.HotSpotDiagnosticMXBean) VMOption(com.sun.management.VMOption) Command(com.shulie.instrument.simulator.api.annotation.Command)

Example 8 with VMOption

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);
}
Also used : HotSpotDiagnosticMXBean(com.sun.management.HotSpotDiagnosticMXBean) VMOption(com.sun.management.VMOption)

Example 9 with VMOption

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);
}
Also used : VMOption(com.sun.management.VMOption)

Aggregations

VMOption (com.sun.management.VMOption)9 HotSpotDiagnosticMXBean (com.sun.management.HotSpotDiagnosticMXBean)5 Command (com.shulie.instrument.simulator.api.annotation.Command)2 VmOption (com.shulie.instrument.simulator.module.model.vmoption.VmOption)1 ArrayList (java.util.ArrayList)1 MBeanServer (javax.management.MBeanServer)1