com.sun.management.VMOption.Origin Java Examples

The following examples show how to use com.sun.management.VMOption.Origin. 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 File: Flag.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
Flag(String name, Object value, boolean writeable,
     boolean external, Origin origin) {
    this.name = name;
    this.value = value == null ? "" : value ;
    this.origin = origin;
    this.writeable = writeable;
    this.external = external;
}
 
Example #2
Source File: Flag.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
Flag(String name, Object value, boolean writeable,
     boolean external, Origin origin) {
    this.name = name;
    this.value = value == null ? "" : value ;
    this.origin = origin;
    this.writeable = writeable;
    this.external = external;
}
 
Example #3
Source File: Flag.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
Flag(String name, Object value, boolean writeable,
     boolean external, Origin origin) {
    this.name = name;
    this.value = value == null ? "" : value ;
    this.origin = origin;
    this.writeable = writeable;
    this.external = external;
}
 
Example #4
Source File: Flag.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
Flag(String name, Object value, boolean writeable,
     boolean external, Origin origin) {
    this.name = name;
    this.value = value == null ? "" : value ;
    this.origin = origin;
    this.writeable = writeable;
    this.external = external;
}
 
Example #5
Source File: CheckOrigin.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void checkOrigin(String option, Origin origin) throws Exception
{
    Origin o = mbean.getVMOption(option).getOrigin();
    if (!o.equals(origin)) {
        throw new Exception("Option '" + option + "' should have origin '" + origin + "' but had '" + o + "'");
    }
    System.out.println("Option '" + option + "' verified origin = '" + origin + "'");
}
 
Example #6
Source File: Flag.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
Flag(String name, Object value, boolean writeable,
     boolean external, Origin origin) {
    this.name = name;
    this.value = value == null ? "" : value ;
    this.origin = origin;
    this.writeable = writeable;
    this.external = external;
}
 
Example #7
Source File: Flag.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
Flag(String name, Object value, boolean writeable,
     boolean external, Origin origin) {
    this.name = name;
    this.value = value == null ? "" : value ;
    this.origin = origin;
    this.writeable = writeable;
    this.external = external;
}
 
Example #8
Source File: Flag.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
Flag(String name, Object value, boolean writeable,
     boolean external, Origin origin) {
    this.name = name;
    this.value = value == null ? "" : value ;
    this.origin = origin;
    this.writeable = writeable;
    this.external = external;
}
 
Example #9
Source File: Flag.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
Flag(String name, Object value, boolean writeable,
     boolean external, Origin origin) {
    this.name = name;
    this.value = value == null ? "" : value ;
    this.origin = origin;
    this.writeable = writeable;
    this.external = external;
}
 
Example #10
Source File: Flag.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
Flag(String name, Object value, boolean writeable,
     boolean external, Origin origin) {
    this.name = name;
    this.value = value == null ? "" : value ;
    this.origin = origin;
    this.writeable = writeable;
    this.external = external;
}
 
Example #11
Source File: Flag.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
Flag(String name, Object value, boolean writeable,
     boolean external, Origin origin) {
    this.name = name;
    this.value = value == null ? "" : value ;
    this.origin = origin;
    this.writeable = writeable;
    this.external = external;
}
 
Example #12
Source File: Flag.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
Flag(String name, Object value, boolean writeable,
     boolean external, Origin origin) {
    this.name = name;
    this.value = value == null ? "" : value ;
    this.origin = origin;
    this.writeable = writeable;
    this.external = external;
}
 
Example #13
Source File: Flag.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
Flag(String name, Object value, boolean writeable,
     boolean external, Origin origin) {
    this.name = name;
    this.value = value == null ? "" : value ;
    this.origin = origin;
    this.writeable = writeable;
    this.external = external;
}
 
Example #14
Source File: Flag.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
Flag(String name, Object value, boolean writeable,
     boolean external, Origin origin) {
    this.name = name;
    this.value = value == null ? "" : value ;
    this.origin = origin;
    this.writeable = writeable;
    this.external = external;
}
 
Example #15
Source File: SetVMOption.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    mbean =
        ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);

    VMOption option = findPrintGCDetailsOption();
    if (!option.getValue().equalsIgnoreCase(EXPECTED_VALUE)) {
        throw new RuntimeException("Unexpected value: " +
            option.getValue() + " expected: " + EXPECTED_VALUE);
    }
    if (option.getOrigin() != Origin.VM_CREATION) {
        throw new RuntimeException("Unexpected origin: " +
            option.getOrigin() + " expected: VM_CREATION");
    }
    if (!option.isWriteable()) {
        throw new RuntimeException("Expected " + PRINT_GC_DETAILS +
            " to be writeable");
    }

    // set VM option to a new value
    mbean.setVMOption(PRINT_GC_DETAILS, NEW_VALUE);

    option = findPrintGCDetailsOption();
    if (!option.getValue().equalsIgnoreCase(NEW_VALUE)) {
        throw new RuntimeException("Unexpected value: " +
            option.getValue() + " expected: " + NEW_VALUE);
    }
    if (option.getOrigin() != Origin.MANAGEMENT) {
        throw new RuntimeException("Unexpected origin: " +
            option.getOrigin() + " expected: MANAGEMENT");
    }
    VMOption o = mbean.getVMOption(PRINT_GC_DETAILS);
    if (!option.getValue().equals(o.getValue())) {
        throw new RuntimeException("Unmatched value: " +
            option.getValue() + " expected: " + o.getValue());
    }
    if (!option.getValue().equals(o.getValue())) {
        throw new RuntimeException("Unmatched value: " +
            option.getValue() + " expected: " + o.getValue());
    }
    if (option.getOrigin() != o.getOrigin()) {
        throw new RuntimeException("Unmatched origin: " +
            option.getOrigin() + " expected: " + o.getOrigin());
    }
    if (option.isWriteable() != o.isWriteable()) {
        throw new RuntimeException("Unmatched writeable: " +
            option.isWriteable() + " expected: " + o.isWriteable());
    }

    // check if ManagementServer is not writeable
    List<VMOption> options = mbean.getDiagnosticOptions();
    VMOption mgmtServerOption = null;
    for (VMOption o1 : options) {
        if (o1.getName().equals(MANAGEMENT_SERVER)) {
             mgmtServerOption = o1;
             break;
        }
    }
    if (mgmtServerOption != null) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " is not expected to be writeable");
    }
    mgmtServerOption = mbean.getVMOption(MANAGEMENT_SERVER);
    if (mgmtServerOption == null) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " should exist.");
    }
    if (mgmtServerOption.getOrigin() != Origin.DEFAULT) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " should have the default value.");
    }
    if (mgmtServerOption.isWriteable()) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " is not expected to be writeable");
    }
}
 
Example #16
Source File: VMOptionCompositeData.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static Origin getOrigin(CompositeData cd) {
    String o = getString(cd, ORIGIN);
    return Enum.valueOf(Origin.class, o);
}
 
Example #17
Source File: VMOptionCompositeData.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static Origin getOrigin(CompositeData cd) {
    String o = getString(cd, ORIGIN);
    return Enum.valueOf(Origin.class, o);
}
 
Example #18
Source File: SetVMOption.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    mbean =
        ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);

    VMOption option = findPrintGCDetailsOption();
    if (!option.getValue().equalsIgnoreCase(EXPECTED_VALUE)) {
        throw new RuntimeException("Unexpected value: " +
            option.getValue() + " expected: " + EXPECTED_VALUE);
    }
    if (option.getOrigin() != Origin.VM_CREATION) {
        throw new RuntimeException("Unexpected origin: " +
            option.getOrigin() + " expected: VM_CREATION");
    }
    if (!option.isWriteable()) {
        throw new RuntimeException("Expected " + PRINT_GC_DETAILS +
            " to be writeable");
    }

    // set VM option to a new value
    mbean.setVMOption(PRINT_GC_DETAILS, NEW_VALUE);

    option = findPrintGCDetailsOption();
    if (!option.getValue().equalsIgnoreCase(NEW_VALUE)) {
        throw new RuntimeException("Unexpected value: " +
            option.getValue() + " expected: " + NEW_VALUE);
    }
    if (option.getOrigin() != Origin.MANAGEMENT) {
        throw new RuntimeException("Unexpected origin: " +
            option.getOrigin() + " expected: MANAGEMENT");
    }
    VMOption o = mbean.getVMOption(PRINT_GC_DETAILS);
    if (!option.getValue().equals(o.getValue())) {
        throw new RuntimeException("Unmatched value: " +
            option.getValue() + " expected: " + o.getValue());
    }
    if (!option.getValue().equals(o.getValue())) {
        throw new RuntimeException("Unmatched value: " +
            option.getValue() + " expected: " + o.getValue());
    }
    if (option.getOrigin() != o.getOrigin()) {
        throw new RuntimeException("Unmatched origin: " +
            option.getOrigin() + " expected: " + o.getOrigin());
    }
    if (option.isWriteable() != o.isWriteable()) {
        throw new RuntimeException("Unmatched writeable: " +
            option.isWriteable() + " expected: " + o.isWriteable());
    }

    // check if ManagementServer is not writeable
    List<VMOption> options = mbean.getDiagnosticOptions();
    VMOption mgmtServerOption = null;
    for (VMOption o1 : options) {
        if (o1.getName().equals(MANAGEMENT_SERVER)) {
             mgmtServerOption = o1;
             break;
        }
    }
    if (mgmtServerOption != null) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " is not expected to be writeable");
    }
    mgmtServerOption = mbean.getVMOption(MANAGEMENT_SERVER);
    if (mgmtServerOption == null) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " should exist.");
    }
    if (mgmtServerOption.getOrigin() != Origin.DEFAULT) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " should have the default value.");
    }
    if (mgmtServerOption.isWriteable()) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " is not expected to be writeable");
    }
}
 
Example #19
Source File: VMOptionCompositeData.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public static Origin getOrigin(CompositeData cd) {
    String o = getString(cd, ORIGIN);
    return Enum.valueOf(Origin.class, o);
}
 
Example #20
Source File: SetVMOption.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    mbean =
        ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);

    VMOption option = findPrintGCDetailsOption();
    if (!option.getValue().equalsIgnoreCase(EXPECTED_VALUE)) {
        throw new RuntimeException("Unexpected value: " +
            option.getValue() + " expected: " + EXPECTED_VALUE);
    }
    if (option.getOrigin() != Origin.VM_CREATION) {
        throw new RuntimeException("Unexpected origin: " +
            option.getOrigin() + " expected: VM_CREATION");
    }
    if (!option.isWriteable()) {
        throw new RuntimeException("Expected " + PRINT_GC_DETAILS +
            " to be writeable");
    }

    // set VM option to a new value
    mbean.setVMOption(PRINT_GC_DETAILS, NEW_VALUE);

    option = findPrintGCDetailsOption();
    if (!option.getValue().equalsIgnoreCase(NEW_VALUE)) {
        throw new RuntimeException("Unexpected value: " +
            option.getValue() + " expected: " + NEW_VALUE);
    }
    if (option.getOrigin() != Origin.MANAGEMENT) {
        throw new RuntimeException("Unexpected origin: " +
            option.getOrigin() + " expected: MANAGEMENT");
    }
    VMOption o = mbean.getVMOption(PRINT_GC_DETAILS);
    if (!option.getValue().equals(o.getValue())) {
        throw new RuntimeException("Unmatched value: " +
            option.getValue() + " expected: " + o.getValue());
    }
    if (!option.getValue().equals(o.getValue())) {
        throw new RuntimeException("Unmatched value: " +
            option.getValue() + " expected: " + o.getValue());
    }
    if (option.getOrigin() != o.getOrigin()) {
        throw new RuntimeException("Unmatched origin: " +
            option.getOrigin() + " expected: " + o.getOrigin());
    }
    if (option.isWriteable() != o.isWriteable()) {
        throw new RuntimeException("Unmatched writeable: " +
            option.isWriteable() + " expected: " + o.isWriteable());
    }

    // check if ManagementServer is not writeable
    List<VMOption> options = mbean.getDiagnosticOptions();
    VMOption mgmtServerOption = null;
    for (VMOption o1 : options) {
        if (o1.getName().equals(MANAGEMENT_SERVER)) {
             mgmtServerOption = o1;
             break;
        }
    }
    if (mgmtServerOption != null) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " is not expected to be writeable");
    }
    mgmtServerOption = mbean.getVMOption(MANAGEMENT_SERVER);
    if (mgmtServerOption == null) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " should exist.");
    }
    if (mgmtServerOption.getOrigin() != Origin.DEFAULT) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " should have the default value.");
    }
    if (mgmtServerOption.isWriteable()) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " is not expected to be writeable");
    }
}
 
Example #21
Source File: SetVMOption.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    mbean =
        ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);

    VMOption option = findPrintGCDetailsOption();
    if (!option.getValue().equalsIgnoreCase(EXPECTED_VALUE)) {
        throw new RuntimeException("Unexpected value: " +
            option.getValue() + " expected: " + EXPECTED_VALUE);
    }
    if (option.getOrigin() != Origin.VM_CREATION) {
        throw new RuntimeException("Unexpected origin: " +
            option.getOrigin() + " expected: VM_CREATION");
    }
    if (!option.isWriteable()) {
        throw new RuntimeException("Expected " + PRINT_GC_DETAILS +
            " to be writeable");
    }

    // set VM option to a new value
    mbean.setVMOption(PRINT_GC_DETAILS, NEW_VALUE);

    option = findPrintGCDetailsOption();
    if (!option.getValue().equalsIgnoreCase(NEW_VALUE)) {
        throw new RuntimeException("Unexpected value: " +
            option.getValue() + " expected: " + NEW_VALUE);
    }
    if (option.getOrigin() != Origin.MANAGEMENT) {
        throw new RuntimeException("Unexpected origin: " +
            option.getOrigin() + " expected: MANAGEMENT");
    }
    VMOption o = mbean.getVMOption(PRINT_GC_DETAILS);
    if (!option.getValue().equals(o.getValue())) {
        throw new RuntimeException("Unmatched value: " +
            option.getValue() + " expected: " + o.getValue());
    }
    if (!option.getValue().equals(o.getValue())) {
        throw new RuntimeException("Unmatched value: " +
            option.getValue() + " expected: " + o.getValue());
    }
    if (option.getOrigin() != o.getOrigin()) {
        throw new RuntimeException("Unmatched origin: " +
            option.getOrigin() + " expected: " + o.getOrigin());
    }
    if (option.isWriteable() != o.isWriteable()) {
        throw new RuntimeException("Unmatched writeable: " +
            option.isWriteable() + " expected: " + o.isWriteable());
    }

    // check if ManagementServer is not writeable
    List<VMOption> options = mbean.getDiagnosticOptions();
    VMOption mgmtServerOption = null;
    for (VMOption o1 : options) {
        if (o1.getName().equals(MANAGEMENT_SERVER)) {
             mgmtServerOption = o1;
             break;
        }
    }
    if (mgmtServerOption != null) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " is not expected to be writeable");
    }
    mgmtServerOption = mbean.getVMOption(MANAGEMENT_SERVER);
    if (mgmtServerOption == null) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " should exist.");
    }
    if (mgmtServerOption.getOrigin() != Origin.DEFAULT) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " should have the default value.");
    }
    if (mgmtServerOption.isWriteable()) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " is not expected to be writeable");
    }
}
 
Example #22
Source File: VMOptionCompositeData.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public static Origin getOrigin(CompositeData cd) {
    String o = getString(cd, ORIGIN);
    return Enum.valueOf(Origin.class, o);
}
 
Example #23
Source File: VMOptionCompositeData.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static Origin getOrigin(CompositeData cd) {
    String o = getString(cd, ORIGIN);
    return Enum.valueOf(Origin.class, o);
}
 
Example #24
Source File: SetVMOption.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    mbean =
        ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);

    VMOption option = findPrintGCDetailsOption();
    if (!option.getValue().equalsIgnoreCase(EXPECTED_VALUE)) {
        throw new RuntimeException("Unexpected value: " +
            option.getValue() + " expected: " + EXPECTED_VALUE);
    }
    if (option.getOrigin() != Origin.VM_CREATION) {
        throw new RuntimeException("Unexpected origin: " +
            option.getOrigin() + " expected: VM_CREATION");
    }
    if (!option.isWriteable()) {
        throw new RuntimeException("Expected " + PRINT_GC_DETAILS +
            " to be writeable");
    }

    // set VM option to a new value
    mbean.setVMOption(PRINT_GC_DETAILS, NEW_VALUE);

    option = findPrintGCDetailsOption();
    if (!option.getValue().equalsIgnoreCase(NEW_VALUE)) {
        throw new RuntimeException("Unexpected value: " +
            option.getValue() + " expected: " + NEW_VALUE);
    }
    if (option.getOrigin() != Origin.MANAGEMENT) {
        throw new RuntimeException("Unexpected origin: " +
            option.getOrigin() + " expected: MANAGEMENT");
    }
    VMOption o = mbean.getVMOption(PRINT_GC_DETAILS);
    if (!option.getValue().equals(o.getValue())) {
        throw new RuntimeException("Unmatched value: " +
            option.getValue() + " expected: " + o.getValue());
    }
    if (!option.getValue().equals(o.getValue())) {
        throw new RuntimeException("Unmatched value: " +
            option.getValue() + " expected: " + o.getValue());
    }
    if (option.getOrigin() != o.getOrigin()) {
        throw new RuntimeException("Unmatched origin: " +
            option.getOrigin() + " expected: " + o.getOrigin());
    }
    if (option.isWriteable() != o.isWriteable()) {
        throw new RuntimeException("Unmatched writeable: " +
            option.isWriteable() + " expected: " + o.isWriteable());
    }

    // check if ManagementServer is not writeable
    List<VMOption> options = mbean.getDiagnosticOptions();
    VMOption mgmtServerOption = null;
    for (VMOption o1 : options) {
        if (o1.getName().equals(MANAGEMENT_SERVER)) {
             mgmtServerOption = o1;
             break;
        }
    }
    if (mgmtServerOption != null) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " is not expected to be writeable");
    }
    mgmtServerOption = mbean.getVMOption(MANAGEMENT_SERVER);
    if (mgmtServerOption == null) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " should exist.");
    }
    if (mgmtServerOption.getOrigin() != Origin.DEFAULT) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " should have the default value.");
    }
    if (mgmtServerOption.isWriteable()) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " is not expected to be writeable");
    }
}
 
Example #25
Source File: SetVMOption.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    mbean =
        ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);

    VMOption option = findPrintGCDetailsOption();
    if (!option.getValue().equalsIgnoreCase(EXPECTED_VALUE)) {
        throw new RuntimeException("Unexpected value: " +
            option.getValue() + " expected: " + EXPECTED_VALUE);
    }
    if (option.getOrigin() != Origin.VM_CREATION) {
        throw new RuntimeException("Unexpected origin: " +
            option.getOrigin() + " expected: VM_CREATION");
    }
    if (!option.isWriteable()) {
        throw new RuntimeException("Expected " + PRINT_GC_DETAILS +
            " to be writeable");
    }

    // set VM option to a new value
    mbean.setVMOption(PRINT_GC_DETAILS, NEW_VALUE);

    option = findPrintGCDetailsOption();
    if (!option.getValue().equalsIgnoreCase(NEW_VALUE)) {
        throw new RuntimeException("Unexpected value: " +
            option.getValue() + " expected: " + NEW_VALUE);
    }
    if (option.getOrigin() != Origin.MANAGEMENT) {
        throw new RuntimeException("Unexpected origin: " +
            option.getOrigin() + " expected: MANAGEMENT");
    }
    VMOption o = mbean.getVMOption(PRINT_GC_DETAILS);
    if (!option.getValue().equals(o.getValue())) {
        throw new RuntimeException("Unmatched value: " +
            option.getValue() + " expected: " + o.getValue());
    }
    if (!option.getValue().equals(o.getValue())) {
        throw new RuntimeException("Unmatched value: " +
            option.getValue() + " expected: " + o.getValue());
    }
    if (option.getOrigin() != o.getOrigin()) {
        throw new RuntimeException("Unmatched origin: " +
            option.getOrigin() + " expected: " + o.getOrigin());
    }
    if (option.isWriteable() != o.isWriteable()) {
        throw new RuntimeException("Unmatched writeable: " +
            option.isWriteable() + " expected: " + o.isWriteable());
    }

    // check if ManagementServer is not writeable
    List<VMOption> options = mbean.getDiagnosticOptions();
    VMOption mgmtServerOption = null;
    for (VMOption o1 : options) {
        if (o1.getName().equals(MANAGEMENT_SERVER)) {
             mgmtServerOption = o1;
             break;
        }
    }
    if (mgmtServerOption != null) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " is not expected to be writeable");
    }
    mgmtServerOption = mbean.getVMOption(MANAGEMENT_SERVER);
    if (mgmtServerOption == null) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " should exist.");
    }
    if (mgmtServerOption.getOrigin() != Origin.DEFAULT) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " should have the default value.");
    }
    if (mgmtServerOption.isWriteable()) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " is not expected to be writeable");
    }
}
 
Example #26
Source File: VMOptionCompositeData.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public static Origin getOrigin(CompositeData cd) {
    String o = getString(cd, ORIGIN);
    return Enum.valueOf(Origin.class, o);
}
 
Example #27
Source File: SetVMOption.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    mbean =
        ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);

    VMOption option = findPrintGCDetailsOption();
    if (!option.getValue().equalsIgnoreCase(EXPECTED_VALUE)) {
        throw new RuntimeException("Unexpected value: " +
            option.getValue() + " expected: " + EXPECTED_VALUE);
    }
    if (option.getOrigin() != Origin.VM_CREATION) {
        throw new RuntimeException("Unexpected origin: " +
            option.getOrigin() + " expected: VM_CREATION");
    }
    if (!option.isWriteable()) {
        throw new RuntimeException("Expected " + PRINT_GC_DETAILS +
            " to be writeable");
    }

    // set VM option to a new value
    mbean.setVMOption(PRINT_GC_DETAILS, NEW_VALUE);

    option = findPrintGCDetailsOption();
    if (!option.getValue().equalsIgnoreCase(NEW_VALUE)) {
        throw new RuntimeException("Unexpected value: " +
            option.getValue() + " expected: " + NEW_VALUE);
    }
    if (option.getOrigin() != Origin.MANAGEMENT) {
        throw new RuntimeException("Unexpected origin: " +
            option.getOrigin() + " expected: MANAGEMENT");
    }
    VMOption o = mbean.getVMOption(PRINT_GC_DETAILS);
    if (!option.getValue().equals(o.getValue())) {
        throw new RuntimeException("Unmatched value: " +
            option.getValue() + " expected: " + o.getValue());
    }
    if (!option.getValue().equals(o.getValue())) {
        throw new RuntimeException("Unmatched value: " +
            option.getValue() + " expected: " + o.getValue());
    }
    if (option.getOrigin() != o.getOrigin()) {
        throw new RuntimeException("Unmatched origin: " +
            option.getOrigin() + " expected: " + o.getOrigin());
    }
    if (option.isWriteable() != o.isWriteable()) {
        throw new RuntimeException("Unmatched writeable: " +
            option.isWriteable() + " expected: " + o.isWriteable());
    }

    // check if ManagementServer is not writeable
    List<VMOption> options = mbean.getDiagnosticOptions();
    VMOption mgmtServerOption = null;
    for (VMOption o1 : options) {
        if (o1.getName().equals(MANAGEMENT_SERVER)) {
             mgmtServerOption = o1;
             break;
        }
    }
    if (mgmtServerOption != null) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " is not expected to be writeable");
    }
    mgmtServerOption = mbean.getVMOption(MANAGEMENT_SERVER);
    if (mgmtServerOption == null) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " should exist.");
    }
    if (mgmtServerOption.getOrigin() != Origin.DEFAULT) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " should have the default value.");
    }
    if (mgmtServerOption.isWriteable()) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " is not expected to be writeable");
    }
}
 
Example #28
Source File: VMOptionCompositeData.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static Origin getOrigin(CompositeData cd) {
    String o = getString(cd, ORIGIN);
    return Enum.valueOf(Origin.class, o);
}
 
Example #29
Source File: SetVMOption.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    mbean =
        ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);

    VMOption option = findHeapDumpOnOomOption();
    if (!option.getValue().equalsIgnoreCase(EXPECTED_VALUE)) {
        throw new RuntimeException("Unexpected value: " +
            option.getValue() + " expected: " + EXPECTED_VALUE);
    }
    if (option.getOrigin() != Origin.VM_CREATION) {
        throw new RuntimeException("Unexpected origin: " +
            option.getOrigin() + " expected: VM_CREATION");
    }
    if (!option.isWriteable()) {
        throw new RuntimeException("Expected " + HEAP_DUMP_ON_OOM +
            " to be writeable");
    }

    // set VM option to a new value
    mbean.setVMOption(HEAP_DUMP_ON_OOM, NEW_VALUE);

    option = findHeapDumpOnOomOption();
    if (!option.getValue().equalsIgnoreCase(NEW_VALUE)) {
        throw new RuntimeException("Unexpected value: " +
            option.getValue() + " expected: " + NEW_VALUE);
    }
    if (option.getOrigin() != Origin.MANAGEMENT) {
        throw new RuntimeException("Unexpected origin: " +
            option.getOrigin() + " expected: MANAGEMENT");
    }
    VMOption o = mbean.getVMOption(HEAP_DUMP_ON_OOM);
    if (!option.getValue().equals(o.getValue())) {
        throw new RuntimeException("Unmatched value: " +
            option.getValue() + " expected: " + o.getValue());
    }
    if (!option.getValue().equals(o.getValue())) {
        throw new RuntimeException("Unmatched value: " +
            option.getValue() + " expected: " + o.getValue());
    }
    if (option.getOrigin() != o.getOrigin()) {
        throw new RuntimeException("Unmatched origin: " +
            option.getOrigin() + " expected: " + o.getOrigin());
    }
    if (option.isWriteable() != o.isWriteable()) {
        throw new RuntimeException("Unmatched writeable: " +
            option.isWriteable() + " expected: " + o.isWriteable());
    }

    // check if ManagementServer is not writeable
    List<VMOption> options = mbean.getDiagnosticOptions();
    VMOption mgmtServerOption = null;
    for (VMOption o1 : options) {
        if (o1.getName().equals(MANAGEMENT_SERVER)) {
             mgmtServerOption = o1;
             break;
        }
    }
    if (mgmtServerOption != null) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " is not expected to be writeable");
    }
    mgmtServerOption = mbean.getVMOption(MANAGEMENT_SERVER);
    if (mgmtServerOption == null) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " should exist.");
    }
    if (mgmtServerOption.getOrigin() != Origin.DEFAULT) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " should have the default value.");
    }
    if (mgmtServerOption.isWriteable()) {
        throw new RuntimeException(MANAGEMENT_SERVER +
            " is not expected to be writeable");
    }
}
 
Example #30
Source File: CheckOrigin.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String... args) throws Exception {
    if (args.length == 0) {
        // start a process that has options set in a number of different ways

        File flagsFile = File.createTempFile("CheckOriginFlags", null);
        try (PrintWriter pw =
               new PrintWriter(new FileWriter(flagsFile))) {
            pw.println("+PrintSafepointStatistics");
        }

        ProcessBuilder pb = ProcessTools.
            createJavaProcessBuilder(
                "--add-exports", "jdk.attach/sun.tools.attach=ALL-UNNAMED",
                "-XX:+UseConcMarkSweepGC",  // this will cause UseParNewGC to be FLAG_SET_ERGO
                "-XX:+UseCodeAging",
                "-XX:+UseCerealGC",         // Should be ignored.
                "-XX:Flags=" + flagsFile.getAbsolutePath(),
                "-Djdk.attach.allowAttachSelf",
                "-cp", System.getProperty("test.class.path"),
                "CheckOrigin",
                "-runtests");

        Map<String, String> env = pb.environment();
        // "UseCMSGC" should be ignored.
        env.put("_JAVA_OPTIONS", "-XX:+CheckJNICalls -XX:+UseCMSGC");
        // "UseGOneGC" should be ignored.
        env.put("JAVA_TOOL_OPTIONS", "-XX:+IgnoreUnrecognizedVMOptions "
            + "-XX:+PrintVMOptions -XX:+UseGOneGC");

        pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
        pb.redirectError(ProcessBuilder.Redirect.INHERIT);
        Process p = pb.start();
        int exit = p.waitFor();
        System.out.println("sub process exit == " + exit);
        if (exit != 0) {
            throw new Exception("Unexpected exit code from subprocess == " + exit);
        }
    } else {
        mbean =
            ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);

        // set a few more options
        mbean.setVMOption("HeapDumpOnOutOfMemoryError", "true");
        setOptionUsingAttach("HeapDumpPath", "/a/sample/path");

        // check the origin field for all the options we set

        // Not set, so should be default
        checkOrigin("ManagementServer", Origin.DEFAULT);
        // Set on the command line
        checkOrigin("UseCodeAging", Origin.VM_CREATION);
        // Set in _JAVA_OPTIONS
        checkOrigin("CheckJNICalls", Origin.ENVIRON_VAR);
        // Set in JAVA_TOOL_OPTIONS
        checkOrigin("IgnoreUnrecognizedVMOptions", Origin.ENVIRON_VAR);
        checkOrigin("PrintVMOptions", Origin.ENVIRON_VAR);
        // Set in -XX:Flags file
        checkOrigin("PrintSafepointStatistics", Origin.CONFIG_FILE);
        // Set through j.l.m
        checkOrigin("HeapDumpOnOutOfMemoryError", Origin.MANAGEMENT);
        // Should be set by the VM, when we set UseConcMarkSweepGC
        checkOrigin("UseParNewGC", Origin.ERGONOMIC);
        // Set using attach
        checkOrigin("HeapDumpPath", Origin.ATTACH_ON_DEMAND);
    }
}