< prev index next >

test/lib/sun/hotspot/WhiteBox.java

Print this page
rev 1371 : 8074980: add WhiteBox API to get a flag value for a method
Reviewed-by:

@@ -25,10 +25,11 @@
 package sun.hotspot;
 
 import java.lang.reflect.Executable;
 import java.util.Arrays;
 import java.util.List;
+import java.util.function.BiFunction;
 import java.util.function.Function;
 import java.util.stream.Stream;
 import java.security.BasicPermission;
 
 import sun.hotspot.parser.DiagnosticCommand;

@@ -248,9 +249,26 @@
     if (offset == -1) {
       throw new RuntimeException(name + " not found");
     }
     return offset;
   }
+  public native Boolean getMethodBooleanOption(Executable method, String name);
+  public native Long    getMethodIntxOption(Executable method, String name);
+  public native Long    getMethodUintxOption(Executable method, String name);
+  public native Double  getMethodDoubleOption(Executable method, String name);
+  public native String  getMethodStringOption(Executable method, String name);
+  private final List<BiFunction<Executable,String,Object>> methodOptionGetters
+      = Arrays.asList(this::getMethodBooleanOption, this::getMethodIntxOption,
+          this::getMethodUintxOption, this::getMethodDoubleOption,
+          this::getMethodStringOption);
+
+  public Object getMethodOption(Executable method, String name) {
+    return methodOptionGetters.stream()
+                              .map(f -> f.apply(method, name))
+                              .filter(x -> x != null)
+                              .findAny()
+                              .orElse(null);
+  }
 
   // Safepoint Checking
   public native void assertMatchingSafepointCalls(boolean mutexSafepointValue, boolean attemptedNoSafepointValue);
 }
< prev index next >