Java Code Examples for java.lang.management.RuntimeMXBean#getSystemProperties()
The following examples show how to use
java.lang.management.RuntimeMXBean#getSystemProperties() .
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: SystemPropertyInformation.java From hivemq-community-edition with Apache License 2.0 | 5 votes |
public String getSystemPropertyInformation() { final StringBuilder systemPropertyBuilder = new StringBuilder(); final RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean(); final Map<String, String> systemProperties = runtimeBean.getSystemProperties(); final Set<String> keys = systemProperties.keySet(); for (final String key : keys) { final String value = systemProperties.get(key); addInformation(systemPropertyBuilder, key, value); } return systemPropertyBuilder.toString(); }
Example 2
Source File: TestHeapSize.java From hbase with Apache License 2.0 | 5 votes |
@BeforeClass public static void beforeClass() throws Exception { // Print detail on jvm so we know what is different should below test fail. RuntimeMXBean b = ManagementFactory.getRuntimeMXBean(); LOG.info("name=" + b.getName()); LOG.info("specname=" + b.getSpecName()); LOG.info("specvendor=" + b.getSpecVendor()); LOG.info("vmname=" + b.getVmName()); LOG.info("vmversion=" + b.getVmVersion()); LOG.info("vmvendor=" + b.getVmVendor()); Map<String, String> p = b.getSystemProperties(); LOG.info("properties=" + p); }
Example 3
Source File: JMServer.java From jmonitor with GNU General Public License v2.0 | 5 votes |
@HttpMapping(url = "/loadRuntimeInfo") public JSONObject doLoadRuntimeInfo(Map<String, Object> param) { try { String app = ((HttpServletRequest) param.get(JMDispatcher.REQ)).getParameter("app"); RuntimeMXBean mBean = JMConnManager.getRuntimeMBean(app); ClassLoadingMXBean cBean = JMConnManager.getClassMbean(app); Map<String, String> props = mBean.getSystemProperties(); DateFormat format = DateFormat.getInstance(); List<String> input = mBean.getInputArguments(); Date date = new Date(mBean.getStartTime()); TreeMap<String, Object> data = new TreeMap<String, Object>(); data.put("apppid", mBean.getName()); data.put("startparam", input.toString()); data.put("starttime", format.format(date)); data.put("classLoadedNow", cBean.getLoadedClassCount()); data.put("classUnloadedAll", cBean.getUnloadedClassCount()); data.put("classLoadedAll", cBean.getTotalLoadedClassCount()); data.putAll(props); JSONObject json = new JSONObject(true); json.putAll(data); return json; } catch (IOException e) { throw new RuntimeException(e); } }
Example 4
Source File: GetSystemProperties.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
private static void runTest() throws Exception { RuntimeMXBean mbean = ManagementFactory.getRuntimeMXBean(); // Print all system properties Map<String,String> props = mbean.getSystemProperties(); printProperties(props); // Add new system properties System.setProperty(KEY1, VALUE1); System.setProperty(KEY2, VALUE2); Map<String,String> props1 = mbean.getSystemProperties(); String value1 = props1.get(KEY1); if (value1 == null || !value1.equals(VALUE1)) { throw new RuntimeException(KEY1 + " property found" + " with value = " + value1 + " but expected to be " + VALUE1); } String value2 = props1.get(KEY2); if (value2 == null || !value2.equals(VALUE2)) { throw new RuntimeException(KEY2 + " property found" + " with value = " + value2 + " but expected to be " + VALUE2); } String value3 = props1.get(KEY3); if (value3 != null) { throw new RuntimeException(KEY3 + " property found" + " but should not exist" ); } // Add new system properties but are not Strings Properties sp = System.getProperties(); sp.put(KEY3, VALUE3); sp.put(KEY4, VALUE4); Map<String,String> props2 = mbean.getSystemProperties(); // expect the system properties returned should be // same as the one before adding KEY3 and KEY4 if (!props1.equals(props2)) { throw new RuntimeException("Two copies of system properties " + "are expected to be equal"); } System.out.println("Test passed."); }
Example 5
Source File: GetSystemProperties.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
private static void runTest() throws Exception { RuntimeMXBean mbean = ManagementFactory.getRuntimeMXBean(); // Print all system properties Map<String,String> props = mbean.getSystemProperties(); printProperties(props); // Add new system properties System.setProperty(KEY1, VALUE1); System.setProperty(KEY2, VALUE2); Map<String,String> props1 = mbean.getSystemProperties(); String value1 = props1.get(KEY1); if (value1 == null || !value1.equals(VALUE1)) { throw new RuntimeException(KEY1 + " property found" + " with value = " + value1 + " but expected to be " + VALUE1); } String value2 = props1.get(KEY2); if (value2 == null || !value2.equals(VALUE2)) { throw new RuntimeException(KEY2 + " property found" + " with value = " + value2 + " but expected to be " + VALUE2); } String value3 = props1.get(KEY3); if (value3 != null) { throw new RuntimeException(KEY3 + " property found" + " but should not exist" ); } // Add new system properties but are not Strings Properties sp = System.getProperties(); sp.put(KEY3, VALUE3); sp.put(KEY4, VALUE4); Map<String,String> props2 = mbean.getSystemProperties(); // expect the system properties returned should be // same as the one before adding KEY3 and KEY4 if (!props1.equals(props2)) { throw new RuntimeException("Two copies of system properties " + "are expected to be equal"); } System.out.println("Test passed."); }
Example 6
Source File: GetSystemProperties.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
private static void runTest() throws Exception { RuntimeMXBean mbean = ManagementFactory.getRuntimeMXBean(); // Print all system properties Map<String,String> props = mbean.getSystemProperties(); printProperties(props); // Add new system properties System.setProperty(KEY1, VALUE1); System.setProperty(KEY2, VALUE2); Map<String,String> props1 = mbean.getSystemProperties(); String value1 = props1.get(KEY1); if (value1 == null || !value1.equals(VALUE1)) { throw new RuntimeException(KEY1 + " property found" + " with value = " + value1 + " but expected to be " + VALUE1); } String value2 = props1.get(KEY2); if (value2 == null || !value2.equals(VALUE2)) { throw new RuntimeException(KEY2 + " property found" + " with value = " + value2 + " but expected to be " + VALUE2); } String value3 = props1.get(KEY3); if (value3 != null) { throw new RuntimeException(KEY3 + " property found" + " but should not exist" ); } // Add new system properties but are not Strings Properties sp = System.getProperties(); sp.put(KEY3, VALUE3); sp.put(KEY4, VALUE4); Map<String,String> props2 = mbean.getSystemProperties(); // expect the system properties returned should be // same as the one before adding KEY3 and KEY4 if (!props1.equals(props2)) { throw new RuntimeException("Two copies of system properties " + "are expected to be equal"); } System.out.println("Test passed."); }
Example 7
Source File: GetSystemProperties.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
private static void runTest() throws Exception { RuntimeMXBean mbean = ManagementFactory.getRuntimeMXBean(); // Print all system properties Map<String,String> props = mbean.getSystemProperties(); printProperties(props); // Add new system properties System.setProperty(KEY1, VALUE1); System.setProperty(KEY2, VALUE2); Map<String,String> props1 = mbean.getSystemProperties(); String value1 = props1.get(KEY1); if (value1 == null || !value1.equals(VALUE1)) { throw new RuntimeException(KEY1 + " property found" + " with value = " + value1 + " but expected to be " + VALUE1); } String value2 = props1.get(KEY2); if (value2 == null || !value2.equals(VALUE2)) { throw new RuntimeException(KEY2 + " property found" + " with value = " + value2 + " but expected to be " + VALUE2); } String value3 = props1.get(KEY3); if (value3 != null) { throw new RuntimeException(KEY3 + " property found" + " but should not exist" ); } // Add new system properties but are not Strings Properties sp = System.getProperties(); sp.put(KEY3, VALUE3); sp.put(KEY4, VALUE4); Map<String,String> props2 = mbean.getSystemProperties(); // expect the system properties returned should be // same as the one before adding KEY3 and KEY4 if (!props1.equals(props2)) { throw new RuntimeException("Two copies of system properties " + "are expected to be equal"); } System.out.println("Test passed."); }
Example 8
Source File: GetSystemProperties.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private static void runTest() throws Exception { RuntimeMXBean mbean = ManagementFactory.getRuntimeMXBean(); // Print all system properties Map<String,String> props = mbean.getSystemProperties(); printProperties(props); // Add new system properties System.setProperty(KEY1, VALUE1); System.setProperty(KEY2, VALUE2); Map<String,String> props1 = mbean.getSystemProperties(); String value1 = props1.get(KEY1); if (value1 == null || !value1.equals(VALUE1)) { throw new RuntimeException(KEY1 + " property found" + " with value = " + value1 + " but expected to be " + VALUE1); } String value2 = props1.get(KEY2); if (value2 == null || !value2.equals(VALUE2)) { throw new RuntimeException(KEY2 + " property found" + " with value = " + value2 + " but expected to be " + VALUE2); } String value3 = props1.get(KEY3); if (value3 != null) { throw new RuntimeException(KEY3 + " property found" + " but should not exist" ); } // Add new system properties but are not Strings Properties sp = System.getProperties(); sp.put(KEY3, VALUE3); sp.put(KEY4, VALUE4); Map<String,String> props2 = mbean.getSystemProperties(); // expect the system properties returned should be // same as the one before adding KEY3 and KEY4 if (!props1.equals(props2)) { throw new RuntimeException("Two copies of system properties " + "are expected to be equal"); } System.out.println("Test passed."); }
Example 9
Source File: GetSystemProperties.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
private static void runTest() throws Exception { RuntimeMXBean mbean = ManagementFactory.getRuntimeMXBean(); // Print all system properties Map<String,String> props = mbean.getSystemProperties(); printProperties(props); // Add new system properties System.setProperty(KEY1, VALUE1); System.setProperty(KEY2, VALUE2); Map<String,String> props1 = mbean.getSystemProperties(); String value1 = props1.get(KEY1); if (value1 == null || !value1.equals(VALUE1)) { throw new RuntimeException(KEY1 + " property found" + " with value = " + value1 + " but expected to be " + VALUE1); } String value2 = props1.get(KEY2); if (value2 == null || !value2.equals(VALUE2)) { throw new RuntimeException(KEY2 + " property found" + " with value = " + value2 + " but expected to be " + VALUE2); } String value3 = props1.get(KEY3); if (value3 != null) { throw new RuntimeException(KEY3 + " property found" + " but should not exist" ); } // Add new system properties but are not Strings Properties sp = System.getProperties(); sp.put(KEY3, VALUE3); sp.put(KEY4, VALUE4); Map<String,String> props2 = mbean.getSystemProperties(); // expect the system properties returned should be // same as the one before adding KEY3 and KEY4 if (!props1.equals(props2)) { throw new RuntimeException("Two copies of system properties " + "are expected to be equal"); } System.out.println("Test passed."); }
Example 10
Source File: GetSystemProperties.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
private static void runTest() throws Exception { RuntimeMXBean mbean = ManagementFactory.getRuntimeMXBean(); // Print all system properties Map<String,String> props = mbean.getSystemProperties(); printProperties(props); // Add new system properties System.setProperty(KEY1, VALUE1); System.setProperty(KEY2, VALUE2); Map<String,String> props1 = mbean.getSystemProperties(); String value1 = props1.get(KEY1); if (value1 == null || !value1.equals(VALUE1)) { throw new RuntimeException(KEY1 + " property found" + " with value = " + value1 + " but expected to be " + VALUE1); } String value2 = props1.get(KEY2); if (value2 == null || !value2.equals(VALUE2)) { throw new RuntimeException(KEY2 + " property found" + " with value = " + value2 + " but expected to be " + VALUE2); } String value3 = props1.get(KEY3); if (value3 != null) { throw new RuntimeException(KEY3 + " property found" + " but should not exist" ); } // Add new system properties but are not Strings Properties sp = System.getProperties(); sp.put(KEY3, VALUE3); sp.put(KEY4, VALUE4); Map<String,String> props2 = mbean.getSystemProperties(); // expect the system properties returned should be // same as the one before adding KEY3 and KEY4 if (!props1.equals(props2)) { throw new RuntimeException("Two copies of system properties " + "are expected to be equal"); } System.out.println("Test passed."); }
Example 11
Source File: GetSystemProperties.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
private static void runTest() throws Exception { RuntimeMXBean mbean = ManagementFactory.getRuntimeMXBean(); // Print all system properties Map<String,String> props = mbean.getSystemProperties(); printProperties(props); // Add new system properties System.setProperty(KEY1, VALUE1); System.setProperty(KEY2, VALUE2); Map<String,String> props1 = mbean.getSystemProperties(); String value1 = props1.get(KEY1); if (value1 == null || !value1.equals(VALUE1)) { throw new RuntimeException(KEY1 + " property found" + " with value = " + value1 + " but expected to be " + VALUE1); } String value2 = props1.get(KEY2); if (value2 == null || !value2.equals(VALUE2)) { throw new RuntimeException(KEY2 + " property found" + " with value = " + value2 + " but expected to be " + VALUE2); } String value3 = props1.get(KEY3); if (value3 != null) { throw new RuntimeException(KEY3 + " property found" + " but should not exist" ); } // Add new system properties but are not Strings Properties sp = System.getProperties(); sp.put(KEY3, VALUE3); sp.put(KEY4, VALUE4); Map<String,String> props2 = mbean.getSystemProperties(); // expect the system properties returned should be // same as the one before adding KEY3 and KEY4 if (!props1.equals(props2)) { throw new RuntimeException("Two copies of system properties " + "are expected to be equal"); } System.out.println("Test passed."); }
Example 12
Source File: GetSystemProperties.java From hottub with GNU General Public License v2.0 | 4 votes |
private static void runTest() throws Exception { RuntimeMXBean mbean = ManagementFactory.getRuntimeMXBean(); // Print all system properties Map<String,String> props = mbean.getSystemProperties(); printProperties(props); // Add new system properties System.setProperty(KEY1, VALUE1); System.setProperty(KEY2, VALUE2); Map<String,String> props1 = mbean.getSystemProperties(); String value1 = props1.get(KEY1); if (value1 == null || !value1.equals(VALUE1)) { throw new RuntimeException(KEY1 + " property found" + " with value = " + value1 + " but expected to be " + VALUE1); } String value2 = props1.get(KEY2); if (value2 == null || !value2.equals(VALUE2)) { throw new RuntimeException(KEY2 + " property found" + " with value = " + value2 + " but expected to be " + VALUE2); } String value3 = props1.get(KEY3); if (value3 != null) { throw new RuntimeException(KEY3 + " property found" + " but should not exist" ); } // Add new system properties but are not Strings Properties sp = System.getProperties(); sp.put(KEY3, VALUE3); sp.put(KEY4, VALUE4); Map<String,String> props2 = mbean.getSystemProperties(); // expect the system properties returned should be // same as the one before adding KEY3 and KEY4 if (!props1.equals(props2)) { throw new RuntimeException("Two copies of system properties " + "are expected to be equal"); } System.out.println("Test passed."); }
Example 13
Source File: GetSystemProperties.java From native-obfuscator with GNU General Public License v3.0 | 4 votes |
private static void runTest() throws Exception { RuntimeMXBean mbean = ManagementFactory.getRuntimeMXBean(); // Print all system properties Map<String,String> props = mbean.getSystemProperties(); // Add new system properties System.setProperty(KEY1, VALUE1); System.setProperty(KEY2, VALUE2); Map<String,String> props1 = mbean.getSystemProperties(); String value1 = props1.get(KEY1); if (value1 == null || !value1.equals(VALUE1)) { throw new RuntimeException(KEY1 + " property found" + " with value = " + value1 + " but expected to be " + VALUE1); } String value2 = props1.get(KEY2); if (value2 == null || !value2.equals(VALUE2)) { throw new RuntimeException(KEY2 + " property found" + " with value = " + value2 + " but expected to be " + VALUE2); } String value3 = props1.get(KEY3); if (value3 != null) { throw new RuntimeException(KEY3 + " property found" + " but should not exist" ); } // Add new system properties but are not Strings Properties sp = System.getProperties(); sp.put(KEY3, VALUE3); sp.put(KEY4, VALUE4); Map<String,String> props2 = mbean.getSystemProperties(); // expect the system properties returned should be // same as the one before adding KEY3 and KEY4 if (!props1.equals(props2)) { throw new RuntimeException("Two copies of system properties " + "are expected to be equal"); } System.out.println("Test passed."); }
Example 14
Source File: GetSystemProperties.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private static void runTest() throws Exception { RuntimeMXBean mbean = ManagementFactory.getRuntimeMXBean(); // Print all system properties Map<String,String> props = mbean.getSystemProperties(); printProperties(props); // Add new system properties System.setProperty(KEY1, VALUE1); System.setProperty(KEY2, VALUE2); Map<String,String> props1 = mbean.getSystemProperties(); String value1 = props1.get(KEY1); if (value1 == null || !value1.equals(VALUE1)) { throw new RuntimeException(KEY1 + " property found" + " with value = " + value1 + " but expected to be " + VALUE1); } String value2 = props1.get(KEY2); if (value2 == null || !value2.equals(VALUE2)) { throw new RuntimeException(KEY2 + " property found" + " with value = " + value2 + " but expected to be " + VALUE2); } String value3 = props1.get(KEY3); if (value3 != null) { throw new RuntimeException(KEY3 + " property found" + " but should not exist" ); } // Add new system properties but are not Strings Properties sp = System.getProperties(); sp.put(KEY3, VALUE3); sp.put(KEY4, VALUE4); Map<String,String> props2 = mbean.getSystemProperties(); // expect the system properties returned should be // same as the one before adding KEY3 and KEY4 if (!props1.equals(props2)) { throw new RuntimeException("Two copies of system properties " + "are expected to be equal"); } System.out.println("Test passed."); }
Example 15
Source File: GetSystemProperties.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
private static void runTest() throws Exception { RuntimeMXBean mbean = ManagementFactory.getRuntimeMXBean(); // Print all system properties Map<String,String> props = mbean.getSystemProperties(); printProperties(props); // Add new system properties System.setProperty(KEY1, VALUE1); System.setProperty(KEY2, VALUE2); Map<String,String> props1 = mbean.getSystemProperties(); String value1 = props1.get(KEY1); if (value1 == null || !value1.equals(VALUE1)) { throw new RuntimeException(KEY1 + " property found" + " with value = " + value1 + " but expected to be " + VALUE1); } String value2 = props1.get(KEY2); if (value2 == null || !value2.equals(VALUE2)) { throw new RuntimeException(KEY2 + " property found" + " with value = " + value2 + " but expected to be " + VALUE2); } String value3 = props1.get(KEY3); if (value3 != null) { throw new RuntimeException(KEY3 + " property found" + " but should not exist" ); } // Add new system properties but are not Strings Properties sp = System.getProperties(); sp.put(KEY3, VALUE3); sp.put(KEY4, VALUE4); Map<String,String> props2 = mbean.getSystemProperties(); // expect the system properties returned should be // same as the one before adding KEY3 and KEY4 if (!props1.equals(props2)) { throw new RuntimeException("Two copies of system properties " + "are expected to be equal"); } System.out.println("Test passed."); }
Example 16
Source File: ClassProfiler.java From openjdk-systemtest with Apache License 2.0 | 4 votes |
private void getStatsViaProxy() { RuntimeMXBean runtimeBean = null; OperatingSystemMXBean osBean = null; LoggingMXBean logBean = null; ClassLoadingMXBean classBean = null; CompilationMXBean compBean = null; // Get the proxies for the runtime, os, log and class MXBeans try { runtimeBean = ManagementFactory.newPlatformMXBeanProxy(this.mbs, ManagementFactory.RUNTIME_MXBEAN_NAME, RuntimeMXBean.class); osBean = ManagementFactory.newPlatformMXBeanProxy(this.mbs, ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME, OperatingSystemMXBean.class); logBean = ManagementFactory.newPlatformMXBeanProxy(this.mbs, LogManager.LOGGING_MXBEAN_NAME, LoggingMXBean.class); classBean = ManagementFactory.newPlatformMXBeanProxy(this.mbs, ManagementFactory.CLASS_LOADING_MXBEAN_NAME, ClassLoadingMXBean.class); // Check the compiler is being used and get the compilation MXBean Map<String, String> props = runtimeBean.getSystemProperties(); String sys_comp = props.get("java.compiler"); if ((sys_comp != null) && (!(sys_comp.equals("")))) { compBean = ManagementFactory.newPlatformMXBeanProxy(this.mbs, ManagementFactory.COMPILATION_MXBEAN_NAME, CompilationMXBean.class); } } catch (IOException ioe) { Message.logOut("A communication problem occurred when accessing the MBeanServerConnection"); ioe.printStackTrace(); Assert.fail("A communication problem occurred when accessing the MBeanServerConnection"); } try { Message.logOut("Starting to write data"); // Record the environment data in the log this.envData.writeData(runtimeBean, osBean, logBean, false); // Record the number of class loaded over time in a csv and record // the class data in the log every 10 seconds int secondsCnt = 0; int writesCnt = 0; while (writesCnt < 30) { // Write out the threadData every 10 seconds if (secondsCnt == 10) { System.out.print("."); this.classData.writeData(classBean, compBean, runtimeBean, true); secondsCnt = 0; writesCnt++; } this.recordClassStats(runtimeBean, classBean); Thread.sleep(1000); secondsCnt++; } } catch (InterruptedException ie) { Message.logOut("The sleeping profiler was interrupted"); ie.printStackTrace(); Assert.fail("The sleeping profiler was interrupted"); } catch (UndeclaredThrowableException ue) { Throwable cause = ue.getCause(); Class<ConnectException> connectExcept = ConnectException.class; Class<UnmarshalException> unmarshalExcept = UnmarshalException.class; if (connectExcept.isInstance(cause) || unmarshalExcept.isInstance(cause)) { // If the exception was caused by a Connect or Unmarshal // Exception, assume the monitored JVM has finished. this.closeCSVFile(); Message.logOut("Exiting as JVM we are connected to has finished"); Assert.fail("Exiting as JVM we are connected to has finished"); } else { Message.logOut(ue.getMessage()); ue.printStackTrace(); Assert.fail(ue.getMessage()); } } finally { this.closeCSVFile(); } }
Example 17
Source File: ClassData.java From openjdk-systemtest with Apache License 2.0 | 4 votes |
/** * This method writes the data retrieved from the ClassLoading and * Compilation MXBeans to the ClassData's log using the MXBeans directly or * through a proxy. * * @param clb * The ClassLoading MXBean used to retrieve information about * loaded classes. * @param cb * The Compilation MXBean used to retrieve compilation * information. * @param rb * The Runtime MXBean used to retrieve general information about * the runtime used. * @param append * If the append value is true the data is appended to the log, * otherwise the log is overwritten. */ public void writeData(ClassLoadingMXBean clb, CompilationMXBean cb, RuntimeMXBean rb, boolean append) throws UndeclaredThrowableException { if ((clb == null)) { Assert.fail("ClassLoadingMXBean is null"); } openLogFile(append); DecimalFormat df = new DecimalFormat("#0.00"); // Print out all times to 2 d.p. try { // Record the time and whether the verbose output is enabled out.println("Class Loading and Compilation Information Retrieved at " + DateFormat.getDateTimeInstance().format(new Date())); out.println(""); // Get stats for the class loader, check the values and write them to a file int load_cls_cnt = clb.getLoadedClassCount(); long unload_cls_cnt = clb.getUnloadedClassCount(); long total_cls_cnt = clb.getTotalLoadedClassCount(); // Check the class counts are valid checkClassCounts("proxy", load_cls_cnt, unload_cls_cnt, total_cls_cnt); // Print the results to the log out.println("CLASS LOADING STATS"); out.println(" Current Loaded Class Count: " + load_cls_cnt); out.println(" Total Unloaded Class Count: " + unload_cls_cnt); out.println(" Total Loaded Class Count: " + total_cls_cnt); out.print(" Verbose output enabled: "); if (clb.isVerbose()) { out.println("Yes"); } else { out.println("No"); } out.println(""); out.println(""); // If there is a compiler get the info Map<String, String> props = rb.getSystemProperties(); String sys_comp = props.get("java.compiler"); if ((sys_comp != null) && (!(sys_comp.equals("")))) { // Get the info for the compiler and write to file out.println("COMPILER INFORMATION"); String mxbean_comp = cb.getName(); // Check if the compiler matches the compiler specified in the system properties checkCompiler("proxy", sys_comp, mxbean_comp); out.println(" Just-in-time (JIT) compiler: " + mxbean_comp); if (cb.isCompilationTimeMonitoringSupported()) { out.println(" Total Compilation Time: " + df.format(cb.getTotalCompilationTime() * 1e-3) + " seconds"); // Convert milliseconds to seconds } out.println(""); out.println(""); } closeLogFile(); } catch (UnsupportedOperationException uoe) { Message.logOut("One of the operations you tried is not supported"); uoe.printStackTrace(); Assert.fail("One of the operations you tried is not supported"); } }
Example 18
Source File: GetSystemProperties.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
private static void runTest() throws Exception { RuntimeMXBean mbean = ManagementFactory.getRuntimeMXBean(); // Print all system properties Map<String,String> props = mbean.getSystemProperties(); printProperties(props); // Add new system properties System.setProperty(KEY1, VALUE1); System.setProperty(KEY2, VALUE2); Map<String,String> props1 = mbean.getSystemProperties(); String value1 = props1.get(KEY1); if (value1 == null || !value1.equals(VALUE1)) { throw new RuntimeException(KEY1 + " property found" + " with value = " + value1 + " but expected to be " + VALUE1); } String value2 = props1.get(KEY2); if (value2 == null || !value2.equals(VALUE2)) { throw new RuntimeException(KEY2 + " property found" + " with value = " + value2 + " but expected to be " + VALUE2); } String value3 = props1.get(KEY3); if (value3 != null) { throw new RuntimeException(KEY3 + " property found" + " but should not exist" ); } // Add new system properties but are not Strings Properties sp = System.getProperties(); sp.put(KEY3, VALUE3); sp.put(KEY4, VALUE4); Map<String,String> props2 = mbean.getSystemProperties(); // expect the system properties returned should be // same as the one before adding KEY3 and KEY4 if (!props1.equals(props2)) { throw new RuntimeException("Two copies of system properties " + "are expected to be equal"); } System.out.println("Test passed."); }
Example 19
Source File: GetSystemProperties.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
private static void runTest() throws Exception { RuntimeMXBean mbean = ManagementFactory.getRuntimeMXBean(); // Print all system properties Map<String,String> props = mbean.getSystemProperties(); printProperties(props); // Add new system properties System.setProperty(KEY1, VALUE1); System.setProperty(KEY2, VALUE2); Map<String,String> props1 = mbean.getSystemProperties(); String value1 = props1.get(KEY1); if (value1 == null || !value1.equals(VALUE1)) { throw new RuntimeException(KEY1 + " property found" + " with value = " + value1 + " but expected to be " + VALUE1); } String value2 = props1.get(KEY2); if (value2 == null || !value2.equals(VALUE2)) { throw new RuntimeException(KEY2 + " property found" + " with value = " + value2 + " but expected to be " + VALUE2); } String value3 = props1.get(KEY3); if (value3 != null) { throw new RuntimeException(KEY3 + " property found" + " but should not exist" ); } // Add new system properties but are not Strings Properties sp = System.getProperties(); sp.put(KEY3, VALUE3); sp.put(KEY4, VALUE4); Map<String,String> props2 = mbean.getSystemProperties(); // expect the system properties returned should be // same as the one before adding KEY3 and KEY4 if (!props1.equals(props2)) { throw new RuntimeException("Two copies of system properties " + "are expected to be equal"); } System.out.println("Test passed."); }
Example 20
Source File: SubCommand_Debug.java From QuickShop-Reremake with GNU General Public License v3.0 | 4 votes |
@Override public void onCommand( @NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] cmdArg) { if (cmdArg.length < 1) { switchDebug(sender); return; } switch (cmdArg[0]) { case "debug": case "dev": case "devmode": switchDebug(sender); break; case "handlerlist": if (cmdArg.length < 2) { MsgUtil.sendMessage(sender, "You must given a event"); break; } printHandlerList(sender, cmdArg[1]); break; case "jvm": RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean(); List<String> arguments = runtimeMxBean.getInputArguments(); MsgUtil.sendMessage(sender, ChatColor.GOLD + "Arguments: " + ChatColor.AQUA + Util.list2String(arguments)); MsgUtil.sendMessage(sender, ChatColor.GOLD + "Name: " + ChatColor.AQUA + runtimeMxBean.getName()); MsgUtil.sendMessage(sender, ChatColor.GOLD + "VM Name: " + ChatColor.AQUA + runtimeMxBean.getVmName()); MsgUtil.sendMessage(sender, ChatColor.GOLD + "Uptime: " + ChatColor.AQUA + runtimeMxBean.getUptime()); MsgUtil.sendMessage(sender, ChatColor.GOLD + "JVM Ver: " + ChatColor.AQUA + runtimeMxBean.getVmVersion()); Map<String, String> sys = runtimeMxBean.getSystemProperties(); List<String> sysData = new ArrayList<>(); sys.keySet().forEach(key -> sysData.add(key + "=" + sys.get(key))); MsgUtil.sendMessage(sender, ChatColor.GOLD + "Sys Pro: " + ChatColor.AQUA + Util.list2String(sysData)); break; default: MsgUtil.sendMessage(sender, "Error, no correct args given."); break; } }