com.sun.management.VMOption Java Examples

The following examples show how to use com.sun.management.VMOption. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: TencentKona-8   Author: Tencent   File: GetVMOption.java    License: GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example #2
Source Project: jdk8u-dev-jdk   Author: frohoff   File: GetVMOption.java    License: GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example #3
Source Project: openjdk-8   Author: bpupadhyaya   File: GetVMOption.java    License: GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example #4
Source Project: jdk8u-jdk   Author: frohoff   File: GetVMOption.java    License: GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example #5
Source Project: dragonwell8_jdk   Author: alibaba   File: HotSpotDiagnostic.java    License: GNU General Public License v2.0 5 votes vote down vote up
public List<VMOption> getDiagnosticOptions() {
    List<Flag> allFlags = Flag.getAllFlags();
    List<VMOption> result = new ArrayList<>();
    for (Flag flag : allFlags) {
        if (flag.isWriteable() && flag.isExternal()) {
            result.add(flag.getVMOption());
        }
    }
    return result;
}
 
Example #6
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: GetDoubleVMOption.java    License: GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #7
Source Project: dragonwell8_jdk   Author: alibaba   File: MappedMXBeanType.java    License: GNU General Public License v2.0 5 votes vote down vote up
Object toOpenTypeData(Object data) throws OpenDataException {
    if (data instanceof MemoryUsage) {
        return MemoryUsageCompositeData.toCompositeData((MemoryUsage) data);
    }

    if (data instanceof ThreadInfo) {
        return ThreadInfoCompositeData.toCompositeData((ThreadInfo) data);
    }

    if (data instanceof LockInfo) {
        if (data instanceof java.lang.management.MonitorInfo) {
            return MonitorInfoCompositeData.toCompositeData((MonitorInfo) data);
        }
        return LockInfoCompositeData.toCompositeData((LockInfo) data);
    }

    if (data instanceof MemoryNotificationInfo) {
        return MemoryNotifInfoCompositeData.
            toCompositeData((MemoryNotificationInfo) data);
    }

    if (data instanceof VMOption) {
        return VMOptionCompositeData.toCompositeData((VMOption) data);
    }

    if (isCompositeData) {
        // Classes that implement CompositeData
        //
        // construct a new CompositeDataSupport object
        // so that no other classes are sent over the wire
        CompositeData cd = (CompositeData) data;
        CompositeType ct = cd.getCompositeType();
        String[] itemNames = ct.keySet().toArray(new String[0]);
        Object[] itemValues = cd.getAll(itemNames);
        return new CompositeDataSupport(ct, itemNames, itemValues);
    }

    throw new OpenDataException(javaClass.getName() +
        " is not supported for platform MXBeans");
}
 
Example #8
Source Project: dragonwell8_jdk   Author: alibaba   File: SetVMOption.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static VMOption findPrintGCDetailsOption() {
    List<VMOption> options = mbean.getDiagnosticOptions();
    VMOption gcDetails = null;
    for (VMOption o : options) {
        if (o.getName().equals(PRINT_GC_DETAILS)) {
             gcDetails = o;
             break;
        }
    }
    if (gcDetails == null) {
        throw new RuntimeException("VM option " + PRINT_GC_DETAILS +
            " not found");
    }
    return gcDetails;
}
 
Example #9
Source Project: openjdk-8-source   Author: keerath   File: TestG1HeapRegionSize.java    License: GNU General Public License v2.0 5 votes vote down vote up
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());
  }
}
 
Example #10
Source Project: dragonwell8_jdk   Author: alibaba   File: SetAllVMOptions.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void setAllVMOptions(HotSpotDiagnosticMXBean mbean) {
    List<VMOption> options = mbean.getDiagnosticOptions();
    for (VMOption opt : options) {
        String name = opt.getName();
        String val = opt.getValue();
        System.out.println("option: "+name+"="+val);
        mbean.setVMOption(name,val);
    }
}
 
Example #11
Source Project: hottub   Author: dsrg-uoft   File: TestSummarizeRSetStatsTools.java    License: GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #12
Source Project: TencentKona-8   Author: Tencent   File: CompilerWhiteBoxTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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());
}
 
Example #13
Source Project: openjdk-8-source   Author: keerath   File: SetVMOption.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static VMOption findPrintGCDetailsOption() {
    List<VMOption> options = mbean.getDiagnosticOptions();
    VMOption gcDetails = null;
    for (VMOption o : options) {
        if (o.getName().equals(PRINT_GC_DETAILS)) {
             gcDetails = o;
             break;
        }
    }
    if (gcDetails == null) {
        throw new RuntimeException("VM option " + PRINT_GC_DETAILS +
            " not found");
    }
    return gcDetails;
}
 
Example #14
Source Project: hottub   Author: dsrg-uoft   File: SetVMOption.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static VMOption findPrintGCDetailsOption() {
    List<VMOption> options = mbean.getDiagnosticOptions();
    VMOption gcDetails = null;
    for (VMOption o : options) {
        if (o.getName().equals(PRINT_GC_DETAILS)) {
             gcDetails = o;
             break;
        }
    }
    if (gcDetails == null) {
        throw new RuntimeException("VM option " + PRINT_GC_DETAILS +
            " not found");
    }
    return gcDetails;
}
 
Example #15
Source Project: TencentKona-8   Author: Tencent   File: MappedMXBeanType.java    License: GNU General Public License v2.0 5 votes vote down vote up
Object toOpenTypeData(Object data) throws OpenDataException {
    if (data instanceof MemoryUsage) {
        return MemoryUsageCompositeData.toCompositeData((MemoryUsage) data);
    }

    if (data instanceof ThreadInfo) {
        return ThreadInfoCompositeData.toCompositeData((ThreadInfo) data);
    }

    if (data instanceof LockInfo) {
        if (data instanceof java.lang.management.MonitorInfo) {
            return MonitorInfoCompositeData.toCompositeData((MonitorInfo) data);
        }
        return LockInfoCompositeData.toCompositeData((LockInfo) data);
    }

    if (data instanceof MemoryNotificationInfo) {
        return MemoryNotifInfoCompositeData.
            toCompositeData((MemoryNotificationInfo) data);
    }

    if (data instanceof VMOption) {
        return VMOptionCompositeData.toCompositeData((VMOption) data);
    }

    if (isCompositeData) {
        // Classes that implement CompositeData
        //
        // construct a new CompositeDataSupport object
        // so that no other classes are sent over the wire
        CompositeData cd = (CompositeData) data;
        CompositeType ct = cd.getCompositeType();
        String[] itemNames = ct.keySet().toArray(new String[0]);
        Object[] itemValues = cd.getAll(itemNames);
        return new CompositeDataSupport(ct, itemNames, itemValues);
    }

    throw new OpenDataException(javaClass.getName() +
        " is not supported for platform MXBeans");
}
 
Example #16
Source Project: hottub   Author: dsrg-uoft   File: MappedMXBeanType.java    License: GNU General Public License v2.0 5 votes vote down vote up
Object toOpenTypeData(Object data) throws OpenDataException {
    if (data instanceof MemoryUsage) {
        return MemoryUsageCompositeData.toCompositeData((MemoryUsage) data);
    }

    if (data instanceof ThreadInfo) {
        return ThreadInfoCompositeData.toCompositeData((ThreadInfo) data);
    }

    if (data instanceof LockInfo) {
        if (data instanceof java.lang.management.MonitorInfo) {
            return MonitorInfoCompositeData.toCompositeData((MonitorInfo) data);
        }
        return LockInfoCompositeData.toCompositeData((LockInfo) data);
    }

    if (data instanceof MemoryNotificationInfo) {
        return MemoryNotifInfoCompositeData.
            toCompositeData((MemoryNotificationInfo) data);
    }

    if (data instanceof VMOption) {
        return VMOptionCompositeData.toCompositeData((VMOption) data);
    }

    if (isCompositeData) {
        // Classes that implement CompositeData
        //
        // construct a new CompositeDataSupport object
        // so that no other classes are sent over the wire
        CompositeData cd = (CompositeData) data;
        CompositeType ct = cd.getCompositeType();
        String[] itemNames = ct.keySet().toArray(new String[0]);
        Object[] itemValues = cd.getAll(itemNames);
        return new CompositeDataSupport(ct, itemNames, itemValues);
    }

    throw new OpenDataException(javaClass.getName() +
        " is not supported for platform MXBeans");
}
 
Example #17
Source Project: openjdk-8-source   Author: keerath   File: HotSpotDiagnostic.java    License: GNU General Public License v2.0 5 votes vote down vote up
public List<VMOption> getDiagnosticOptions() {
    List<Flag> allFlags = Flag.getAllFlags();
    List<VMOption> result = new ArrayList<>();
    for (Flag flag : allFlags) {
        if (flag.isWriteable() && flag.isExternal()) {
            result.add(flag.getVMOption());
        }
    }
    return result;
}
 
Example #18
Source Project: openjdk-8-source   Author: keerath   File: TestSummarizeRSetStatsTools.java    License: GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #19
Source Project: jdk8u_jdk   Author: JetBrains   File: SetVMOption.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static VMOption findPrintGCDetailsOption() {
    List<VMOption> options = mbean.getDiagnosticOptions();
    VMOption gcDetails = null;
    for (VMOption o : options) {
        if (o.getName().equals(PRINT_GC_DETAILS)) {
             gcDetails = o;
             break;
        }
    }
    if (gcDetails == null) {
        throw new RuntimeException("VM option " + PRINT_GC_DETAILS +
            " not found");
    }
    return gcDetails;
}
 
Example #20
Source Project: jdk8u60   Author: chenghanpeng   File: CompilerWhiteBoxTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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());
}
 
Example #21
Source Project: jdk8u60   Author: chenghanpeng   File: HotSpotDiagnostic.java    License: GNU General Public License v2.0 5 votes vote down vote up
public List<VMOption> getDiagnosticOptions() {
    List<Flag> allFlags = Flag.getAllFlags();
    List<VMOption> result = new ArrayList<>();
    for (Flag flag : allFlags) {
        if (flag.isWriteable() && flag.isExternal()) {
            result.add(flag.getVMOption());
        }
    }
    return result;
}
 
Example #22
Source Project: jdk8u60   Author: chenghanpeng   File: HotSpotDiagnostic.java    License: GNU General Public License v2.0 5 votes vote down vote up
public VMOption getVMOption(String name) {
    if (name == null) {
        throw new NullPointerException("name cannot be null");
    }

    Flag f = Flag.getFlag(name);
    if (f == null) {
        throw new IllegalArgumentException("VM option \"" +
            name + "\" does not exist");
    }
    return f.getVMOption();
}
 
Example #23
Source Project: jdk8u60   Author: chenghanpeng   File: MappedMXBeanType.java    License: GNU General Public License v2.0 5 votes vote down vote up
Object toOpenTypeData(Object data) throws OpenDataException {
    if (data instanceof MemoryUsage) {
        return MemoryUsageCompositeData.toCompositeData((MemoryUsage) data);
    }

    if (data instanceof ThreadInfo) {
        return ThreadInfoCompositeData.toCompositeData((ThreadInfo) data);
    }

    if (data instanceof LockInfo) {
        if (data instanceof java.lang.management.MonitorInfo) {
            return MonitorInfoCompositeData.toCompositeData((MonitorInfo) data);
        }
        return LockInfoCompositeData.toCompositeData((LockInfo) data);
    }

    if (data instanceof MemoryNotificationInfo) {
        return MemoryNotifInfoCompositeData.
            toCompositeData((MemoryNotificationInfo) data);
    }

    if (data instanceof VMOption) {
        return VMOptionCompositeData.toCompositeData((VMOption) data);
    }

    if (isCompositeData) {
        // Classes that implement CompositeData
        //
        // construct a new CompositeDataSupport object
        // so that no other classes are sent over the wire
        CompositeData cd = (CompositeData) data;
        CompositeType ct = cd.getCompositeType();
        String[] itemNames = ct.keySet().toArray(new String[0]);
        Object[] itemValues = cd.getAll(itemNames);
        return new CompositeDataSupport(ct, itemNames, itemValues);
    }

    throw new OpenDataException(javaClass.getName() +
        " is not supported for platform MXBeans");
}
 
Example #24
Source Project: jdk8u-jdk   Author: lambdalab-mirror   File: SetAllVMOptions.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void setAllVMOptions(HotSpotDiagnosticMXBean mbean) {
    List<VMOption> options = mbean.getDiagnosticOptions();
    for (VMOption opt : options) {
        String name = opt.getName();
        String val = opt.getValue();
        System.out.println("option: "+name+"="+val);
        mbean.setVMOption(name,val);
    }
}
 
Example #25
Source Project: openjdk-8   Author: bpupadhyaya   File: CompilerWhiteBoxTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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());
}
 
Example #26
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: SetVMOption.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static VMOption findHeapDumpOnOomOption() {
    List<VMOption> options = mbean.getDiagnosticOptions();
    VMOption gcDetails = null;
    for (VMOption o : options) {
        if (o.getName().equals(HEAP_DUMP_ON_OOM)) {
             gcDetails = o;
             break;
        }
    }
    if (gcDetails == null) {
        throw new RuntimeException("VM option " + HEAP_DUMP_ON_OOM +
            " not found");
    }
    return gcDetails;
}
 
Example #27
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: TestUseCompressedOopsErgoTools.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static long getCompressedClassSpaceSize() {
  HotSpotDiagnosticMXBean diagnostic =
      ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);

  VMOption option = diagnostic.getVMOption("CompressedClassSpaceSize");
  return Long.parseLong(option.getValue());
}
 
Example #28
Source Project: jdk8u-dev-jdk   Author: frohoff   File: SetVMOption.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static VMOption findPrintGCDetailsOption() {
    List<VMOption> options = mbean.getDiagnosticOptions();
    VMOption gcDetails = null;
    for (VMOption o : options) {
        if (o.getName().equals(PRINT_GC_DETAILS)) {
             gcDetails = o;
             break;
        }
    }
    if (gcDetails == null) {
        throw new RuntimeException("VM option " + PRINT_GC_DETAILS +
            " not found");
    }
    return gcDetails;
}
 
Example #29
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: HotSpotDiagnostic.java    License: GNU General Public License v2.0 5 votes vote down vote up
public VMOption getVMOption(String name) {
    if (name == null) {
        throw new NullPointerException("name cannot be null");
    }

    Flag f = Flag.getFlag(name);
    if (f == null) {
        throw new IllegalArgumentException("VM option \"" +
            name + "\" does not exist");
    }
    return f.getVMOption();
}
 
Example #30
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: MappedMXBeanType.java    License: GNU General Public License v2.0 5 votes vote down vote up
Object toOpenTypeData(Object data) throws OpenDataException {
    if (data instanceof MemoryUsage) {
        return MemoryUsageCompositeData.toCompositeData((MemoryUsage) data);
    }

    if (data instanceof ThreadInfo) {
        return ThreadInfoCompositeData.toCompositeData((ThreadInfo) data);
    }

    if (data instanceof LockInfo) {
        if (data instanceof java.lang.management.MonitorInfo) {
            return MonitorInfoCompositeData.toCompositeData((MonitorInfo) data);
        }
        return LockInfoCompositeData.toCompositeData((LockInfo) data);
    }

    if (data instanceof MemoryNotificationInfo) {
        return MemoryNotifInfoCompositeData.
            toCompositeData((MemoryNotificationInfo) data);
    }

    if (data instanceof VMOption) {
        return VMOptionCompositeData.toCompositeData((VMOption) data);
    }

    if (isCompositeData) {
        // Classes that implement CompositeData
        //
        // construct a new CompositeDataSupport object
        // so that no other classes are sent over the wire
        CompositeData cd = (CompositeData) data;
        CompositeType ct = cd.getCompositeType();
        String[] itemNames = ct.keySet().toArray(new String[0]);
        Object[] itemValues = cd.getAll(itemNames);
        return new CompositeDataSupport(ct, itemNames, itemValues);
    }

    throw new OpenDataException(javaClass.getName() +
        " is not supported for platform MXBeans");
}