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 File: GetVMOption.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
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 File: GetVMOption.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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 File: GetVMOption.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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 File: GetVMOption.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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 File: MappedMXBeanType.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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 #6
Source File: HotSpotDiagnostic.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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 #7
Source File: SetVMOption.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
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 #8
Source File: TestUseCompressedOopsErgoTools.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static long getCompressedClassSpaceSize() { HotSpotDiagnosticMXBean diagnostic = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class); VMOption option = diagnostic.getVMOption("CompressedClassSpaceSize"); return Long.parseLong(option.getValue()); }
Example #9
Source File: SetVMOption.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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 #10
Source File: CompilerWhiteBoxTest.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * 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 #11
Source File: SetAllVMOptions.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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 #12
Source File: MappedMXBeanType.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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 #13
Source File: HotSpotDiagnostic.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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 #14
Source File: HotSpotDiagnostic.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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 #15
Source File: CompilerWhiteBoxTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * 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 #16
Source File: SetVMOption.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
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 #17
Source File: HotSpotDiagnostic.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
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 File: MappedMXBeanType.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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 #19
Source File: SetAllVMOptions.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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 #20
Source File: MappedMXBeanType.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
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 #21
Source File: VMOptionOpenDataTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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); } }
Example #22
Source File: VMOptionCommand.java From arthas with Apache License 2.0 | 5 votes |
private static void run(CommandProcess process, String name, String value) { try { HotSpotDiagnosticMXBean hotSpotDiagnosticMXBean = ManagementFactory .getPlatformMXBean(HotSpotDiagnosticMXBean.class); if (StringUtils.isBlank(name) && StringUtils.isBlank(value)) { // show all options process.appendResult(new VMOptionModel(hotSpotDiagnosticMXBean.getDiagnosticOptions())); } else if (StringUtils.isBlank(value)) { // view the specified option VMOption option = hotSpotDiagnosticMXBean.getVMOption(name); if (option == null) { process.end(-1, "In order to change the system properties, you must specify the property value."); } else { process.appendResult(new VMOptionModel(Arrays.asList(option))); } } else { VMOption vmOption = hotSpotDiagnosticMXBean.getVMOption(name); String originValue = vmOption.getValue(); // change vm option hotSpotDiagnosticMXBean.setVMOption(name, value); process.appendResult(new MessageModel("Successfully updated the vm option.")); process.appendResult(new VMOptionModel(new ChangeResultVO(name, originValue, hotSpotDiagnosticMXBean.getVMOption(name).getValue()))); } } catch (Throwable t) { logger.error("Error during setting vm option", t); process.end(-1, "Error during setting vm option: " + t.getMessage()); } finally { process.end(); } }
Example #23
Source File: TestSummarizeRSetStatsTools.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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 #24
Source File: TestG1HeapRegionSize.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean(); String expectedValue = getExpectedValue(args); VMOption option = diagnostic.getVMOption("G1HeapRegionSize"); if (!expectedValue.equals(option.getValue())) { throw new RuntimeException("Wrong value for G1HeapRegionSize. Expected " + expectedValue + " but got " + option.getValue()); } }
Example #25
Source File: SetAllVMOptions.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
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 #26
Source File: HotSpotDiagnostic.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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 #27
Source File: HotSpotDiagnostic.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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 #28
Source File: HotSpotDiagnostic.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
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 #29
Source File: HotSpotDiagnostic.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@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; }
Example #30
Source File: SetVMOption.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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; }