Java Code Examples for java.lang.management.RuntimeMXBean#isBootClassPathSupported()

The following examples show how to use java.lang.management.RuntimeMXBean#isBootClassPathSupported() . 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: PitError.java    From pitest with Apache License 2.0 6 votes vote down vote up
private static String info() {
  final RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean();

  return "\n\nPlease copy and paste the information and the complete stacktrace below when reporting an issue\n"
  + "VM : "
  + rt.getVmName()
  + "\n"
  + "Vendor : "
  + rt.getVmVendor()
  + "\n"
  + "Version : "
  + rt.getVmVersion()
  + "\n"
  + "Uptime : "
  + rt.getUptime()
  + "\n"
  + "Input -> "
  + createInputString(rt.getInputArguments())
  + "\n"
  + "BootClassPathSupported : " + rt.isBootClassPathSupported() + "\n";

}
 
Example 2
Source File: MXBeanInteropTest1.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private final int doRuntimeMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- RuntimeMXBean") ;

    try {
        ObjectName runtimeName =
                new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME) ;
        MBeanInfo mbInfo = mbsc.getMBeanInfo(runtimeName);
        errorCount += checkNonEmpty(mbInfo);
        System.out.println("getMBeanInfo\t\t" + mbInfo);
        RuntimeMXBean runtime = null;

        runtime =
                JMX.newMXBeanProxy(mbsc,
                runtimeName,
                RuntimeMXBean.class) ;
        System.out.println("getClassPath\t\t"
                + runtime.getClassPath());
        System.out.println("getInputArguments\t\t"
                + runtime.getInputArguments());
        System.out.println("getLibraryPath\t\t"
                + runtime.getLibraryPath());
        System.out.println("getManagementSpecVersion\t\t"
                + runtime.getManagementSpecVersion());
        System.out.println("getName\t\t"
                + runtime.getName());
        System.out.println("getSpecName\t\t"
                + runtime.getSpecName());
        System.out.println("getSpecVendor\t\t"
                + runtime.getSpecVendor());
        System.out.println("getSpecVersion\t\t"
                + runtime.getSpecVersion());
        System.out.println("getStartTime\t\t"
                + runtime.getStartTime());
        System.out.println("getSystemProperties\t\t"
                + runtime.getSystemProperties());
        System.out.println("getUptime\t\t"
                + runtime.getUptime());
        System.out.println("getVmName\t\t"
                + runtime.getVmName());
        System.out.println("getVmVendor\t\t"
                + runtime.getVmVendor());
        System.out.println("getVmVersion\t\t"
                + runtime.getVmVersion());
        boolean supported = runtime.isBootClassPathSupported() ;
        System.out.println("isBootClassPathSupported\t\t"
                + supported);

        if ( supported ) {
            System.out.println("getBootClassPath\t\t"
                    + runtime.getBootClassPath());
        }

        System.out.println("---- OK\n") ;
    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}
 
Example 3
Source File: MXBeanInteropTest1.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private final int doRuntimeMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- RuntimeMXBean") ;

    try {
        ObjectName runtimeName =
                new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME) ;
        MBeanInfo mbInfo = mbsc.getMBeanInfo(runtimeName);
        errorCount += checkNonEmpty(mbInfo);
        System.out.println("getMBeanInfo\t\t" + mbInfo);
        RuntimeMXBean runtime = null;

        runtime =
                JMX.newMXBeanProxy(mbsc,
                runtimeName,
                RuntimeMXBean.class) ;
        System.out.println("getClassPath\t\t"
                + runtime.getClassPath());
        System.out.println("getInputArguments\t\t"
                + runtime.getInputArguments());
        System.out.println("getLibraryPath\t\t"
                + runtime.getLibraryPath());
        System.out.println("getManagementSpecVersion\t\t"
                + runtime.getManagementSpecVersion());
        System.out.println("getName\t\t"
                + runtime.getName());
        System.out.println("getSpecName\t\t"
                + runtime.getSpecName());
        System.out.println("getSpecVendor\t\t"
                + runtime.getSpecVendor());
        System.out.println("getSpecVersion\t\t"
                + runtime.getSpecVersion());
        System.out.println("getStartTime\t\t"
                + runtime.getStartTime());
        System.out.println("getSystemProperties\t\t"
                + runtime.getSystemProperties());
        System.out.println("getUptime\t\t"
                + runtime.getUptime());
        System.out.println("getVmName\t\t"
                + runtime.getVmName());
        System.out.println("getVmVendor\t\t"
                + runtime.getVmVendor());
        System.out.println("getVmVersion\t\t"
                + runtime.getVmVersion());
        boolean supported = runtime.isBootClassPathSupported() ;
        System.out.println("isBootClassPathSupported\t\t"
                + supported);

        if ( supported ) {
            System.out.println("getBootClassPath\t\t"
                    + runtime.getBootClassPath());
        }

        System.out.println("---- OK\n") ;
    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}
 
Example 4
Source File: MXBeanInteropTest1.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private final int doRuntimeMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- RuntimeMXBean") ;

    try {
        ObjectName runtimeName =
                new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME) ;
        MBeanInfo mbInfo = mbsc.getMBeanInfo(runtimeName);
        errorCount += checkNonEmpty(mbInfo);
        System.out.println("getMBeanInfo\t\t" + mbInfo);
        RuntimeMXBean runtime = null;

        runtime =
                JMX.newMXBeanProxy(mbsc,
                runtimeName,
                RuntimeMXBean.class) ;
        System.out.println("getClassPath\t\t"
                + runtime.getClassPath());
        System.out.println("getInputArguments\t\t"
                + runtime.getInputArguments());
        System.out.println("getLibraryPath\t\t"
                + runtime.getLibraryPath());
        System.out.println("getManagementSpecVersion\t\t"
                + runtime.getManagementSpecVersion());
        System.out.println("getName\t\t"
                + runtime.getName());
        System.out.println("getSpecName\t\t"
                + runtime.getSpecName());
        System.out.println("getSpecVendor\t\t"
                + runtime.getSpecVendor());
        System.out.println("getSpecVersion\t\t"
                + runtime.getSpecVersion());
        System.out.println("getStartTime\t\t"
                + runtime.getStartTime());
        System.out.println("getSystemProperties\t\t"
                + runtime.getSystemProperties());
        System.out.println("getUptime\t\t"
                + runtime.getUptime());
        System.out.println("getVmName\t\t"
                + runtime.getVmName());
        System.out.println("getVmVendor\t\t"
                + runtime.getVmVendor());
        System.out.println("getVmVersion\t\t"
                + runtime.getVmVersion());
        boolean supported = runtime.isBootClassPathSupported() ;
        System.out.println("isBootClassPathSupported\t\t"
                + supported);

        if ( supported ) {
            System.out.println("getBootClassPath\t\t"
                    + runtime.getBootClassPath());
        }

        System.out.println("---- OK\n") ;
    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}
 
Example 5
Source File: MXBeanInteropTest1.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private final int doRuntimeMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- RuntimeMXBean") ;

    try {
        ObjectName runtimeName =
                new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME) ;
        MBeanInfo mbInfo = mbsc.getMBeanInfo(runtimeName);
        errorCount += checkNonEmpty(mbInfo);
        System.out.println("getMBeanInfo\t\t" + mbInfo);
        RuntimeMXBean runtime = null;

        runtime =
                JMX.newMXBeanProxy(mbsc,
                runtimeName,
                RuntimeMXBean.class) ;
        System.out.println("getClassPath\t\t"
                + runtime.getClassPath());
        System.out.println("getInputArguments\t\t"
                + runtime.getInputArguments());
        System.out.println("getLibraryPath\t\t"
                + runtime.getLibraryPath());
        System.out.println("getManagementSpecVersion\t\t"
                + runtime.getManagementSpecVersion());
        System.out.println("getName\t\t"
                + runtime.getName());
        System.out.println("getSpecName\t\t"
                + runtime.getSpecName());
        System.out.println("getSpecVendor\t\t"
                + runtime.getSpecVendor());
        System.out.println("getSpecVersion\t\t"
                + runtime.getSpecVersion());
        System.out.println("getStartTime\t\t"
                + runtime.getStartTime());
        System.out.println("getSystemProperties\t\t"
                + runtime.getSystemProperties());
        System.out.println("getUptime\t\t"
                + runtime.getUptime());
        System.out.println("getVmName\t\t"
                + runtime.getVmName());
        System.out.println("getVmVendor\t\t"
                + runtime.getVmVendor());
        System.out.println("getVmVersion\t\t"
                + runtime.getVmVersion());
        boolean supported = runtime.isBootClassPathSupported() ;
        System.out.println("isBootClassPathSupported\t\t"
                + supported);

        if ( supported ) {
            System.out.println("getBootClassPath\t\t"
                    + runtime.getBootClassPath());
        }

        System.out.println("---- OK\n") ;
    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}
 
Example 6
Source File: MXBeanInteropTest1.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private final int doRuntimeMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- RuntimeMXBean") ;

    try {
        ObjectName runtimeName =
                new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME) ;
        MBeanInfo mbInfo = mbsc.getMBeanInfo(runtimeName);
        errorCount += checkNonEmpty(mbInfo);
        System.out.println("getMBeanInfo\t\t" + mbInfo);
        RuntimeMXBean runtime = null;

        runtime =
                JMX.newMXBeanProxy(mbsc,
                runtimeName,
                RuntimeMXBean.class) ;
        System.out.println("getClassPath\t\t"
                + runtime.getClassPath());
        System.out.println("getInputArguments\t\t"
                + runtime.getInputArguments());
        System.out.println("getLibraryPath\t\t"
                + runtime.getLibraryPath());
        System.out.println("getManagementSpecVersion\t\t"
                + runtime.getManagementSpecVersion());
        System.out.println("getName\t\t"
                + runtime.getName());
        System.out.println("getSpecName\t\t"
                + runtime.getSpecName());
        System.out.println("getSpecVendor\t\t"
                + runtime.getSpecVendor());
        System.out.println("getSpecVersion\t\t"
                + runtime.getSpecVersion());
        System.out.println("getStartTime\t\t"
                + runtime.getStartTime());
        System.out.println("getSystemProperties\t\t"
                + runtime.getSystemProperties());
        System.out.println("getUptime\t\t"
                + runtime.getUptime());
        System.out.println("getVmName\t\t"
                + runtime.getVmName());
        System.out.println("getVmVendor\t\t"
                + runtime.getVmVendor());
        System.out.println("getVmVersion\t\t"
                + runtime.getVmVersion());
        boolean supported = runtime.isBootClassPathSupported() ;
        System.out.println("isBootClassPathSupported\t\t"
                + supported);

        if ( supported ) {
            System.out.println("getBootClassPath\t\t"
                    + runtime.getBootClassPath());
        }

        System.out.println("---- OK\n") ;
    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}
 
Example 7
Source File: MXBeanInteropTest1.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private final int doRuntimeMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- RuntimeMXBean") ;

    try {
        ObjectName runtimeName =
                new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME) ;
        MBeanInfo mbInfo = mbsc.getMBeanInfo(runtimeName);
        errorCount += checkNonEmpty(mbInfo);
        System.out.println("getMBeanInfo\t\t" + mbInfo);
        RuntimeMXBean runtime = null;

        runtime =
                JMX.newMXBeanProxy(mbsc,
                runtimeName,
                RuntimeMXBean.class) ;
        System.out.println("getClassPath\t\t"
                + runtime.getClassPath());
        System.out.println("getInputArguments\t\t"
                + runtime.getInputArguments());
        System.out.println("getLibraryPath\t\t"
                + runtime.getLibraryPath());
        System.out.println("getManagementSpecVersion\t\t"
                + runtime.getManagementSpecVersion());
        System.out.println("getName\t\t"
                + runtime.getName());
        System.out.println("getSpecName\t\t"
                + runtime.getSpecName());
        System.out.println("getSpecVendor\t\t"
                + runtime.getSpecVendor());
        System.out.println("getSpecVersion\t\t"
                + runtime.getSpecVersion());
        System.out.println("getStartTime\t\t"
                + runtime.getStartTime());
        System.out.println("getSystemProperties\t\t"
                + runtime.getSystemProperties());
        System.out.println("getUptime\t\t"
                + runtime.getUptime());
        System.out.println("getVmName\t\t"
                + runtime.getVmName());
        System.out.println("getVmVendor\t\t"
                + runtime.getVmVendor());
        System.out.println("getVmVersion\t\t"
                + runtime.getVmVersion());
        boolean supported = runtime.isBootClassPathSupported() ;
        System.out.println("isBootClassPathSupported\t\t"
                + supported);

        if ( supported ) {
            System.out.println("getBootClassPath\t\t"
                    + runtime.getBootClassPath());
        }

        System.out.println("---- OK\n") ;
    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}
 
Example 8
Source File: SystemInfoHandler.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
/**
 * Get JVM Info - including memory info
 */
public static SimpleOrderedMap<Object> getJvmInfo()
{
  SimpleOrderedMap<Object> jvm = new SimpleOrderedMap<>();

  final String javaVersion = System.getProperty("java.specification.version", "unknown"); 
  final String javaVendor = System.getProperty("java.specification.vendor", "unknown"); 
  final String javaName = System.getProperty("java.specification.name", "unknown"); 
  final String jreVersion = System.getProperty("java.version", "unknown");
  final String jreVendor = System.getProperty("java.vendor", "unknown");
  final String vmVersion = System.getProperty("java.vm.version", "unknown"); 
  final String vmVendor = System.getProperty("java.vm.vendor", "unknown"); 
  final String vmName = System.getProperty("java.vm.name", "unknown"); 

  // Summary Info
  jvm.add( "version", jreVersion + " " + vmVersion);
  jvm.add(NAME, jreVendor + " " + vmName);
  
  // details
  SimpleOrderedMap<Object> java = new SimpleOrderedMap<>();
  java.add( "vendor", javaVendor );
  java.add(NAME, javaName);
  java.add( "version", javaVersion );
  jvm.add( "spec", java );
  SimpleOrderedMap<Object> jre = new SimpleOrderedMap<>();
  jre.add( "vendor", jreVendor );
  jre.add( "version", jreVersion );
  jvm.add( "jre", jre );
  SimpleOrderedMap<Object> vm = new SimpleOrderedMap<>();
  vm.add( "vendor", vmVendor );
  vm.add(NAME, vmName);
  vm.add( "version", vmVersion );
  jvm.add( "vm", vm );
         
  
  Runtime runtime = Runtime.getRuntime();
  jvm.add( "processors", runtime.availableProcessors() );
  
  // not thread safe, but could be thread local
  DecimalFormat df = new DecimalFormat("#.#", DecimalFormatSymbols.getInstance(Locale.ROOT));

  SimpleOrderedMap<Object> mem = new SimpleOrderedMap<>();
  SimpleOrderedMap<Object> raw = new SimpleOrderedMap<>();
  long free = runtime.freeMemory();
  long max = runtime.maxMemory();
  long total = runtime.totalMemory();
  long used = total - free;
  double percentUsed = ((double)(used)/(double)max)*100;
  raw.add("free",  free );
  mem.add("free",  humanReadableUnits(free, df));
  raw.add("total", total );
  mem.add("total", humanReadableUnits(total, df));
  raw.add("max",   max );
  mem.add("max",   humanReadableUnits(max, df));
  raw.add("used",  used );
  mem.add("used",  humanReadableUnits(used, df) + 
          " (%" + df.format(percentUsed) + ")");
  raw.add("used%", percentUsed);

  mem.add("raw", raw);
  jvm.add("memory", mem);

  // JMX properties -- probably should be moved to a different handler
  SimpleOrderedMap<Object> jmx = new SimpleOrderedMap<>();
  try{
    RuntimeMXBean mx = ManagementFactory.getRuntimeMXBean();
    if (mx.isBootClassPathSupported()) {
      jmx.add( "bootclasspath", mx.getBootClassPath());
    }
    jmx.add( "classpath", mx.getClassPath() );

    // the input arguments passed to the Java virtual machine
    // which does not include the arguments to the main method.
    jmx.add( "commandLineArgs", getInputArgumentsRedacted(mx));

    jmx.add( "startTime", new Date(mx.getStartTime()));
    jmx.add( "upTimeMS",  mx.getUptime() );

  }
  catch (Exception e) {
    log.warn("Error getting JMX properties", e);
  }
  jvm.add( "jmx", jmx );
  return jvm;
}
 
Example 9
Source File: MXBeanInteropTest1.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private final int doRuntimeMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- RuntimeMXBean") ;

    try {
        ObjectName runtimeName =
                new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME) ;
        MBeanInfo mbInfo = mbsc.getMBeanInfo(runtimeName);
        errorCount += checkNonEmpty(mbInfo);
        System.out.println("getMBeanInfo\t\t" + mbInfo);
        RuntimeMXBean runtime = null;

        runtime =
                JMX.newMXBeanProxy(mbsc,
                runtimeName,
                RuntimeMXBean.class) ;
        System.out.println("getClassPath\t\t"
                + runtime.getClassPath());
        System.out.println("getInputArguments\t\t"
                + runtime.getInputArguments());
        System.out.println("getLibraryPath\t\t"
                + runtime.getLibraryPath());
        System.out.println("getManagementSpecVersion\t\t"
                + runtime.getManagementSpecVersion());
        System.out.println("getName\t\t"
                + runtime.getName());
        System.out.println("getSpecName\t\t"
                + runtime.getSpecName());
        System.out.println("getSpecVendor\t\t"
                + runtime.getSpecVendor());
        System.out.println("getSpecVersion\t\t"
                + runtime.getSpecVersion());
        System.out.println("getStartTime\t\t"
                + runtime.getStartTime());
        System.out.println("getSystemProperties\t\t"
                + runtime.getSystemProperties());
        System.out.println("getUptime\t\t"
                + runtime.getUptime());
        System.out.println("getVmName\t\t"
                + runtime.getVmName());
        System.out.println("getVmVendor\t\t"
                + runtime.getVmVendor());
        System.out.println("getVmVersion\t\t"
                + runtime.getVmVersion());
        boolean supported = runtime.isBootClassPathSupported() ;
        System.out.println("isBootClassPathSupported\t\t"
                + supported);

        if ( supported ) {
            System.out.println("getBootClassPath\t\t"
                    + runtime.getBootClassPath());
        }

        System.out.println("---- OK\n") ;
    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}