653 * {@code TEST_VM_FLAGLESS} enviroment variable can be used to force this
654 * method to return true and allow any flags.
655 *
656 * @return true if there are no JVM flags
657 */
658 private String isFlagless() {
659 boolean result = true;
660 if (System.getenv("TEST_VM_FLAGLESS") != null) {
661 return "" + result;
662 }
663
664 List<String> allFlags = new ArrayList<String>();
665 Collections.addAll(allFlags, System.getProperty("test.vm.opts", "").trim().split("\\s+"));
666 Collections.addAll(allFlags, System.getProperty("test.java.opts", "").trim().split("\\s+"));
667
668 // check -XX flags
669 var ignoredXXFlags = Set.of(
670 // added by run-test framework
671 "MaxRAMPercentage",
672 // added by test environment
673 "CreateCoredumpOnCrash"
674 );
675 result &= allFlags.stream()
676 .filter(s -> s.startsWith("-XX:"))
677 // map to names:
678 // remove -XX:
679 .map(s -> s.substring(4))
680 // remove +/- from bool flags
681 .map(s -> s.charAt(0) == '+' || s.charAt(0) == '-' ? s.substring(1) : s)
682 // remove =.* from others
683 .map(s -> s.contains("=") ? s.substring(0, s.indexOf('=')) : s)
684 // skip known-to-be-there flags
685 .filter(s -> !ignoredXXFlags.contains(s))
686 .findAny()
687 .isEmpty();
688
689 // check -X flags
690 var ignoredXFlags = Set.of(
691 // default, yet still seen to be explicitly set
692 "mixed"
693 );
|
653 * {@code TEST_VM_FLAGLESS} enviroment variable can be used to force this
654 * method to return true and allow any flags.
655 *
656 * @return true if there are no JVM flags
657 */
658 private String isFlagless() {
659 boolean result = true;
660 if (System.getenv("TEST_VM_FLAGLESS") != null) {
661 return "" + result;
662 }
663
664 List<String> allFlags = new ArrayList<String>();
665 Collections.addAll(allFlags, System.getProperty("test.vm.opts", "").trim().split("\\s+"));
666 Collections.addAll(allFlags, System.getProperty("test.java.opts", "").trim().split("\\s+"));
667
668 // check -XX flags
669 var ignoredXXFlags = Set.of(
670 // added by run-test framework
671 "MaxRAMPercentage",
672 // added by test environment
673 "CreateCoredumpOnCrash",
674 // experimental features unlocking flag does not affect behavior
675 "UnlockExperimentalVMOptions",
676 // all compact headers settings should run flagless tests
677 "UseCompactObjectHeaders"
678 );
679 result &= allFlags.stream()
680 .filter(s -> s.startsWith("-XX:"))
681 // map to names:
682 // remove -XX:
683 .map(s -> s.substring(4))
684 // remove +/- from bool flags
685 .map(s -> s.charAt(0) == '+' || s.charAt(0) == '-' ? s.substring(1) : s)
686 // remove =.* from others
687 .map(s -> s.contains("=") ? s.substring(0, s.indexOf('=')) : s)
688 // skip known-to-be-there flags
689 .filter(s -> !ignoredXXFlags.contains(s))
690 .findAny()
691 .isEmpty();
692
693 // check -X flags
694 var ignoredXFlags = Set.of(
695 // default, yet still seen to be explicitly set
696 "mixed"
697 );
|