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


Java VMOption类代码示例

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


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

示例1: checkVMOption

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

示例2: main

import com.sun.management.VMOption; //导入依赖的package包/类
public static void main(String... args) throws Exception {
    MBeanServerConnection msc = ManagementFactory.getPlatformMBeanServer();
    HotSpotDiagnosticMXBean mxbean =
        ManagementFactory.getPlatformMXBean(msc, HotSpotDiagnosticMXBean.class);


    String[] signatures = new String[] {
        String.class.getName()
    };
    Object obj = msc.invoke(mxbean.getObjectName(), "getVMOption",
        new String[] { "PrintVMOptions"}, signatures);

    CompositeData data = (CompositeData)obj;
    validateType(data);

    VMOption option = mxbean.getVMOption("PrintVMOptions");
    VMOption o = VMOption.from(data);
    assertEquals(option, o);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:VMOptionOpenDataTest.java

示例3: checkVMOption

import com.sun.management.VMOption; //导入依赖的package包/类
private static void checkVMOption(HotSpotDiagnosticMXBean mbean) {
    VMOption option = mbean.getVMOption(HEAP_DUMP_ON_OOM);
    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");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:GetVMOption.java

示例4: main

import com.sun.management.VMOption; //导入依赖的package包/类
public static void main(String[] args) {
    List<BufferPoolMXBean> pools = ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
    for (BufferPoolMXBean pool:pools) {
        System.out.println(String.format(
                "%s %d/%d", 
                pool.getName(), 
                pool.getMemoryUsed(), 
                pool.getTotalCapacity()));
    }
    RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean();
    for (String arg:RuntimemxBean.getInputArguments()) {
        System.out.println(arg); 
    }
    HotSpotDiagnosticMXBean hsdiag = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
    for (VMOption i:hsdiag.getDiagnosticOptions()) {
        System.out.println(i.getName() + ":" + i.getValue());
    }
    System.out.println(hsdiag.getVMOption("MaxDirectMemorySize"));
    System.out.println(sun.misc.VM.maxDirectMemory());
    System.out.println(ByteBuffer.allocateDirect(1000000000));
    System.out.println(ByteBuffer.allocateDirect(1000000000));
    System.out.println(ByteBuffer.allocateDirect(1000000000));
    System.out.println(getDirectMemoryUsed());
}
 
开发者ID:waterguo,项目名称:antsdb,代码行数:25,代码来源:MemoryUtil.java

示例5: getDiagnosticOptions

import com.sun.management.VMOption; //导入依赖的package包/类
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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:HotSpotDiagnostic.java

示例6: getVMOption

import com.sun.management.VMOption; //导入依赖的package包/类
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();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:HotSpotDiagnostic.java

示例7: toOpenTypeData

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

示例8: getVMOption

import com.sun.management.VMOption; //导入依赖的package包/类
/**
 * 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());
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:20,代码来源:CompilerWhiteBoxTest.java

示例9: findPrintGCDetailsOption

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

示例10: setAllVMOptions

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

示例11: getCompressedClassSpaceSize

import com.sun.management.VMOption; //导入依赖的package包/类
private static long getCompressedClassSpaceSize() {
  HotSpotDiagnosticMXBean diagnostic =
      ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);

  VMOption option = diagnostic.getVMOption("CompressedClassSpaceSize");
  return Long.parseLong(option.getValue());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:TestUseCompressedOopsErgoTools.java

示例12: getDiagnosticOptions

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

示例13: getVMOption

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

示例14: 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

示例15: findHeapDumpOnOomOption

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


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