< prev index next >

src/java.base/share/classes/jdk/internal/reflect/NativeMethodAccessorImpl.java

Print this page

        

@@ -24,10 +24,13 @@
  */
 
 package jdk.internal.reflect;
 
 import java.lang.reflect.*;
+
+import jdk.internal.misc.Strands;
+import jdk.internal.misc.VM;
 import sun.reflect.misc.ReflectUtil;
 
 /** Used only for the first few invocations of a Method; afterward,
     switches to bytecode-based implementation */
 

@@ -44,21 +47,23 @@
         throws IllegalArgumentException, InvocationTargetException
     {
         // We can't inflate methods belonging to vm-anonymous classes because
         // that kind of class can't be referred to by name, hence can't be
         // found from the generated bytecode.
-        if (++numInvocations > ReflectionFactory.inflationThreshold()
-                && !ReflectUtil.isVMAnonymousClass(method.getDeclaringClass())) {
+        if (VM.isBooted() && (++numInvocations > ReflectionFactory.inflationThreshold()
+                || Strands.currentStrand() instanceof Fiber)
+                    && !ReflectUtil.isVMAnonymousClass(method.getDeclaringClass())) {
             MethodAccessorImpl acc = (MethodAccessorImpl)
                 new MethodAccessorGenerator().
                     generateMethod(method.getDeclaringClass(),
                                    method.getName(),
                                    method.getParameterTypes(),
                                    method.getReturnType(),
                                    method.getExceptionTypes(),
                                    method.getModifiers());
             parent.setDelegate(acc);
+            return acc.invoke(obj, args);
         }
 
         return invoke0(method, obj, args);
     }
 
< prev index next >