< prev index next >

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

Print this page

        

*** 24,33 **** --- 24,36 ---- */ 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 Constructor; afterward, switches to bytecode-based implementation */
*** 46,64 **** InvocationTargetException { // We can't inflate a constructor belonging to a vm-anonymous class // 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(c.getDeclaringClass())) { ConstructorAccessorImpl acc = (ConstructorAccessorImpl) new MethodAccessorGenerator(). generateConstructor(c.getDeclaringClass(), c.getParameterTypes(), c.getExceptionTypes(), c.getModifiers()); parent.setDelegate(acc); } return newInstance0(c, args); } --- 49,69 ---- InvocationTargetException { // We can't inflate a constructor belonging to a vm-anonymous class // because that kind of class can't be referred to by name, hence can't // be found from the generated bytecode. ! if (VM.isBooted() && (++numInvocations > ReflectionFactory.inflationThreshold() ! || Strands.currentStrand() instanceof Fiber) ! && !ReflectUtil.isVMAnonymousClass(c.getDeclaringClass())) { ConstructorAccessorImpl acc = (ConstructorAccessorImpl) new MethodAccessorGenerator(). generateConstructor(c.getDeclaringClass(), c.getParameterTypes(), c.getExceptionTypes(), c.getModifiers()); parent.setDelegate(acc); + return acc.newInstance(args); } return newInstance0(c, args); }
< prev index next >