8221913: Add GC.selected() jtreg-ext function
authorstefank
Wed, 10 Apr 2019 15:41:03 +0200
changeset 54510 c97a91097f9f
parent 54509 6c291f12969f
child 54511 fbfcebad8e66
8221913: Add GC.selected() jtreg-ext function Reviewed-by: kbarrett, pliden
test/lib/sun/hotspot/gc/GC.java
--- a/test/lib/sun/hotspot/gc/GC.java	Thu Apr 11 14:20:16 2019 +0530
+++ b/test/lib/sun/hotspot/gc/GC.java	Wed Apr 10 15:41:03 2019 +0200
@@ -70,4 +70,16 @@
     public static boolean isSelectedErgonomically() {
         return WB.isGCSelectedErgonomically();
     }
+
+    /**
+     * @return the selected GC.
+     */
+    public static GC selected() {
+      for (GC gc : values()) {
+        if (gc.isSelected()) {
+          return gc;
+        }
+      }
+      throw new IllegalStateException("No selected GC found");
+    }
 }