src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java

Print this page
rev 17771 : 8184777: species logic for BoundMethodHandle doesn't scale, needs refactor

@@ -63,10 +63,25 @@
 
     /** Tell the JVM that we need to change the target of a CallSite. */
     static native void setCallSiteTargetNormal(CallSite site, MethodHandle target);
     static native void setCallSiteTargetVolatile(CallSite site, MethodHandle target);
 
+    private static boolean MSOK;
+    static boolean moduleSystemInitialized() {
+        if (MSOK)  return true;
+        //if (java.lang.reflect.Layer.boot() == null)  return false;
+        try {
+            Class<?> C_Layer = Class.forName("java.lang.reflect.Layer");
+            if (C_Layer.getDeclaredMethod("boot").invoke(null) == null)
+                return false;
+        } catch (ReflectiveOperationException ex) {
+            return false;
+        }
+        MSOK = true;
+        return true;
+    }
+
     /** Represents a context to track nmethod dependencies on CallSite instance target. */
     static class CallSiteContext implements Runnable {
         //@Injected JVM_nmethodBucket* vmdependencies;
 
         static CallSiteContext make(CallSite cs) {