当前位置: 首页>>代码示例>>Java>>正文


Java VMOption.isWriteable方法代码示例

本文整理汇总了Java中com.sun.management.VMOption.isWriteable方法的典型用法代码示例。如果您正苦于以下问题:Java VMOption.isWriteable方法的具体用法?Java VMOption.isWriteable怎么用?Java VMOption.isWriteable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.management.VMOption的用法示例。


在下文中一共展示了VMOption.isWriteable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: assertEquals

import com.sun.management.VMOption; //导入方法依赖的package包/类
private static void assertEquals(VMOption o1, VMOption o2) {
    if (!o1.getName().equals(o2.getName()) ||
        !o1.getOrigin().equals(o2.getOrigin()) ||
        !o1.getValue().equals(o2.getValue()) ||
        o1.isWriteable() != o2.isWriteable()) {
        throw new AssertionError(o1 + " != " + o2);
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:VMOptionOpenDataTest.java

示例2: main

import com.sun.management.VMOption; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    System.out.println("--- VMOptionOpenDataTest-main: Checking that "
            + "MappedMXBeanType.toOpenTypeData supports VMOption");
    Exception failed = null;
    try {
        VMOption vo = new VMOption("toto", "titi", true, VMOption.Origin.OTHER);
        System.out.println("--- Construct a VMOption object: \"" + vo + "\"");

        Object open = MappedMXBeanType.toOpenTypeData(vo, VMOption.class);
        System.out.println("--- Map it to an open type:  \"" + open +" \"");

        Object back = MappedMXBeanType.toJavaTypeData(open, VMOption.class);
        System.out.println("--- Map it back to java type:  \"" + back +" \"");

        if (back == null) {
            failed = new RuntimeException("Failed, mapping back got null.");
        } else if (!(back instanceof VMOption)) {
            failed = new RuntimeException("Failed, not mapped back to a VMOption: "
                    +back.getClass());
        } else {
            VMOption mapBack = (VMOption)back;
            if (!Objects.equals(vo.getName(), mapBack.getName()) ||
                    !Objects.equals(vo.getOrigin(), mapBack.getOrigin()) ||
                    !Objects.equals(vo.getValue(), mapBack.getValue()) ||
                    vo.isWriteable() != mapBack.isWriteable()) {
                failed = new RuntimeException(
                        "Failed, failed to map back the original VMOtion.");
            }
        }
    } catch (OpenDataException | InvalidObjectException ode) {
        failed = ode;
    }
    if (failed == null) {
        System.out.println("--- PASSED!");
    } else {
        System.out.println("--- Failed: "+failed.getMessage());
        throw failed;
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:40,代码来源:VMOptionOpenDataTest.java

示例3: main

import com.sun.management.VMOption; //导入方法依赖的package包/类
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");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:76,代码来源:SetVMOption.java

示例4: main

import com.sun.management.VMOption; //导入方法依赖的package包/类
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");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:76,代码来源:SetVMOption.java


注:本文中的com.sun.management.VMOption.isWriteable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。