# HG changeset patch # User mchernov # Date 1469106461 -10800 # Node ID fdbe314f004f45a37f06fea9d033d84c42c2d397 # Parent fa7ee03739d661b8f01aaac362c064f66717fd0b 8161208: Unable to run jtreg tests with MinimalVM Reviewed-by: dholmes, dfazunen diff -r fa7ee03739d6 -r fdbe314f004f test/jtreg-ext/requires/VMProps.java --- a/test/jtreg-ext/requires/VMProps.java Wed Jul 20 12:52:45 2016 -0700 +++ b/test/jtreg-ext/requires/VMProps.java Thu Jul 21 16:07:41 2016 +0300 @@ -23,8 +23,6 @@ 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; @@ -35,14 +33,18 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import sun.hotspot.gc.GC; +import sun.hotspot.WhiteBox; /** * The Class to be invoked by jtreg prior Test Suite execution to * collect information about VM. + * Do not use any API's that may not be available in all target VMs. * Properties set by this Class will be available in the @requires expressions. */ public class VMProps implements Callable> { + private static final WhiteBox WB = WhiteBox.getWhiteBox(); + /** * Collects information about VM properties. * This method will be invoked by jtreg. @@ -131,17 +133,14 @@ * @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")) { + Boolean isUnlockedCommercialFatures = WB.getBooleanVMFlag("UnlockCommercialFeatures"); + Boolean isFlightRecorder = WB.getBooleanVMFlag("FlightRecorder"); + String startFROptions = WB.getStringVMFlag("StartFlightRecording"); + if (isUnlockedCommercialFatures != null && isUnlockedCommercialFatures) { + if (isFlightRecorder != null && isFlightRecorder) { return "true"; } - if (arguments.contains("-XX:-FlightRecorder")) { - return "false"; - } - if (arguments.stream() - .anyMatch(option -> option.startsWith("-XX:StartFlightRecording"))) { + if (startFROptions != null && !startFROptions.isEmpty()) { return "true"; } }