|
46 | 46 | import java.util.function.Supplier;
|
47 | 47 | import java.util.regex.Matcher;
|
48 | 48 | import java.util.regex.Pattern;
|
| 49 | +import java.util.stream.Collectors; |
| 50 | +import java.util.stream.Stream; |
49 | 51 |
|
50 | 52 | import jdk.test.whitebox.code.Compiler;
|
51 | 53 | import jdk.test.whitebox.cpuinfo.CPUInfo;
|
@@ -80,6 +82,10 @@ public void put(String key, Supplier<String> s) {
|
80 | 82 | }
|
81 | 83 | map.put(key, value);
|
82 | 84 | }
|
| 85 | + |
| 86 | + public void putAll(Map<String, String> map) { |
| 87 | + map.entrySet().forEach(e -> put(e.getKey(), () -> e.getValue())); |
| 88 | + } |
83 | 89 | }
|
84 | 90 |
|
85 | 91 | /**
|
@@ -126,6 +132,7 @@ public Map<String, String> call() {
|
126 | 132 | map.put("release.implementor", this::implementor);
|
127 | 133 | map.put("jdk.containerized", this::jdkContainerized);
|
128 | 134 | map.put("vm.flagless", this::isFlagless);
|
| 135 | + map.putAll(xOptFlags()); // -Xmx4g -> @requires vm.opt.x.Xmx == "4g" ) |
129 | 136 | vmGC(map); // vm.gc.X = true/false
|
130 | 137 | vmOptFinalFlags(map);
|
131 | 138 |
|
@@ -583,9 +590,7 @@ private String isFlagless() {
|
583 | 590 | return "" + "true".equalsIgnoreCase(flagless);
|
584 | 591 | }
|
585 | 592 |
|
586 |
| - List<String> allFlags = new ArrayList<String>(); |
587 |
| - Collections.addAll(allFlags, System.getProperty("test.vm.opts", "").trim().split("\\s+")); |
588 |
| - Collections.addAll(allFlags, System.getProperty("test.java.opts", "").trim().split("\\s+")); |
| 593 | + List<String> allFlags = allFlags().toList(); |
589 | 594 |
|
590 | 595 | // check -XX flags
|
591 | 596 | var ignoredXXFlags = Set.of(
|
@@ -632,6 +637,35 @@ private String isFlagless() {
|
632 | 637 | return "" + result;
|
633 | 638 | }
|
634 | 639 |
|
| 640 | + private Stream<String> allFlags() { |
| 641 | + return Stream.of((System.getProperty("test.vm.opts", "") + " " + System.getProperty("test.java.opts", "")).trim().split("\\s+")); |
| 642 | + } |
| 643 | + |
| 644 | + /** |
| 645 | + * Parses extra options, options that start with -X excluding the |
| 646 | + * bare -X option (as it is not considered an extra option). |
| 647 | + * Ignores extra options not starting with -X |
| 648 | + * |
| 649 | + * This could be improved to handle extra options not starting |
| 650 | + * with -X as well as "standard" options. |
| 651 | + */ |
| 652 | + private Map<String, String> xOptFlags() { |
| 653 | + return allFlags() |
| 654 | + .filter(s -> s.startsWith("-X") && !s.startsWith("-XX:") && !s.equals("-X")) |
| 655 | + .map(s -> s.replaceFirst("-", "")) |
| 656 | + .map(flag -> { |
| 657 | + String[] split = flag.split("[:0123456789]", 2); |
| 658 | + return split.length == 2 ? new String[] {split[0], flag.substring(split[0].length(), flag.length() - split[1].length()), split[1]} |
| 659 | + : split; |
| 660 | + }) |
| 661 | + .collect(Collectors.toMap(a -> "vm.opt.x." + a[0], |
| 662 | + a -> (a.length == 1) |
| 663 | + ? "true" // -Xnoclassgc |
| 664 | + : (a[1].equals(":") |
| 665 | + ? a[2] // ["-XshowSettings", ":", "system"] |
| 666 | + : a[1] + a[2]))); // ["-Xmx", "4", "g"] |
| 667 | + } |
| 668 | + |
635 | 669 | /**
|
636 | 670 | * Dumps the map to the file if the file name is given as the property.
|
637 | 671 | * This functionality could be helpful to know context in the real
|
|
1 commit comments
openjdk-notifier[bot] commentedon Jul 26, 2024
Review
Issues