--- old/test/jtreg-ext/requires/VMProps.java 2016-06-08 14:57:08.500450819 +0300 +++ new/test/jtreg-ext/requires/VMProps.java 2016-06-08 14:57:08.420449512 +0300 @@ -23,6 +23,8 @@ package requires; import java.io.IOException; +import java.lang.management.ManagementFactory; +import java.lang.management.RuntimeMXBean; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; @@ -52,6 +54,7 @@ map.put("vm.flavor", vmFlavor()); map.put("vm.compMode", vmCompMode()); map.put("vm.bits", vmBits()); + map.put("vm.flightRecorder", vmFlightRecorder()); dump(map); return map; } @@ -104,6 +107,27 @@ } /** + * @return "true" if Flight Recorder is enabled, "false" if is disabled. + */ + protected String vmFlightRecorder() { + RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean(); + List arguments = runtimeMxBean.getInputArguments(); + if (arguments.contains("-XX:+UnlockCommercialFeatures")) { + if (arguments.contains("-XX:+FlightRecorder")) { + return "true"; + } + if (arguments.contains("-XX:-FlightRecorder")) { + return "false"; + } + if (arguments.stream() + .anyMatch(option -> option.startsWith("-XX:StartFlightRecording"))) { + return "true"; + } + } + return "false"; + } + + /** * Dumps the map to the file if the file name is given as the property. * This functionality could be helpful to know context in the real * execution. @@ -116,9 +140,9 @@ return; } List lines = new ArrayList<>(); - map.forEach((k,v) -> lines.add(k + ":" + v)); + map.forEach((k, v) -> lines.add(k + ":" + v)); try { - Files.write(Paths.get(dumpFileName), lines); + Files.write(Paths.get(dumpFileName), lines); } catch (IOException e) { throw new RuntimeException("Failed to dump properties into '" + dumpFileName + "'", e); @@ -131,6 +155,6 @@ */ public static void main(String args[]) { Map map = new VMProps().call(); - map.forEach((k,v) -> System.out.println(k + ": '" + v + "'")); + map.forEach((k, v) -> System.out.println(k + ": '" + v + "'")); } }