< prev index next >

test/lib/sun/hotspot/WhiteBox.java

Print this page

        

@@ -25,10 +25,11 @@
 package sun.hotspot;
 
 import java.lang.management.MemoryUsage;
 import java.lang.reflect.Executable;
 import java.util.Arrays;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.function.BiFunction;
 import java.util.function.Function;
 import java.security.BasicPermission;
 import java.util.Objects;

@@ -151,10 +152,52 @@
   public         void addToSystemClassLoaderSearch(String segment) {
     Objects.requireNonNull(segment);
     addToSystemClassLoaderSearch0(segment);
   }
 
+  // GC
+  /**
+   * @returns true if GC was selected by ergonomic
+   */
+  public boolean gcSelectedByErgo() {
+    if (getSupportedGC().size() < 2) {      
+      return false; // nothing to choose from
+    } else {
+      return gcSelectedByErgo0();
+    }
+  }
+  private native boolean gcSelectedByErgo0();
+
+  /**
+   * @return name of the selected GC
+   */
+  public native String getGC();
+  private native boolean supportsSerialGC();
+  private native boolean supportsParallelGC();
+  private native boolean supportsConcMarkSweepGC();
+  private native boolean supportsG1GC();
+
+  /**
+   * @return names of GC supported by the VM
+   */
+  public List<String> getSupportedGC() {
+    List<String> list = new ArrayList<>();
+    if (supportsSerialGC()) {
+        list.add("Serial");
+    }
+    if (supportsParallelGC()) {
+        list.add("Parallel");
+    }
+    if (supportsConcMarkSweepGC()) {
+        list.add("ConcMarkSweep");
+    }
+    if (supportsG1GC()) {
+        list.add("G1");
+    }
+    return list;
+  }
+
   // G1
   public native boolean g1InConcurrentMark();
   private native boolean g1IsHumongous0(Object o);
   public         boolean g1IsHumongous(Object o) {
     Objects.requireNonNull(o);
< prev index next >