< prev index next >

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

Print this page
rev 58565 : 8238358: Implementation of JEP 371: Hidden Classes
Reviewed-by: duke
Contributed-by: mandy.chung@oracle.com, lois.foltan@oracle.com, david.holmes@oracle.com, harold.seigel@oracle.com, serguei.spitsyn@oracle.com, alex.buckley@oracle.com, jamsheed.c.m@oracle.com

*** 25,35 **** package java.lang.invoke; import jdk.internal.access.JavaLangInvokeAccess; import jdk.internal.access.SharedSecrets; - import jdk.internal.org.objectweb.asm.AnnotationVisitor; import jdk.internal.org.objectweb.asm.ClassWriter; import jdk.internal.org.objectweb.asm.MethodVisitor; import jdk.internal.reflect.CallerSensitive; import jdk.internal.reflect.Reflection; import jdk.internal.vm.annotation.ForceInline; --- 25,34 ----
*** 38,47 **** --- 37,47 ---- import sun.invoke.empty.Empty; import sun.invoke.util.ValueConversions; import sun.invoke.util.VerifyType; import sun.invoke.util.Wrapper; + import java.lang.invoke.MethodHandles.Lookup; import java.lang.reflect.Array; import java.nio.ByteOrder; import java.util.Arrays; import java.util.Collections; import java.util.HashMap;
*** 1155,1168 **** // Cache the result of makeInjectedInvoker once per argument class. MethodHandle bccInvoker = CV_makeInjectedInvoker.get(hostClass); return restoreToType(bccInvoker.bindTo(vamh), mh, hostClass); } ! private static MethodHandle makeInjectedInvoker(Class<?> hostClass) { try { ! Class<?> invokerClass = UNSAFE.defineAnonymousClass(hostClass, INJECTED_INVOKER_TEMPLATE, null); ! assert checkInjectedInvoker(hostClass, invokerClass); return IMPL_LOOKUP.findStatic(invokerClass, "invoke_V", INVOKER_MT); } catch (ReflectiveOperationException ex) { throw uncaughtException(ex); } } --- 1155,1182 ---- // Cache the result of makeInjectedInvoker once per argument class. MethodHandle bccInvoker = CV_makeInjectedInvoker.get(hostClass); return restoreToType(bccInvoker.bindTo(vamh), mh, hostClass); } ! private static MethodHandle makeInjectedInvoker(Class<?> targetClass) { try { ! /* ! * The invoker class defined to the same class loader as the lookup class ! * but in an unnamed package so that the class bytes can be cached and ! * reused for any @CSM. ! * ! * @CSM must be public and exported if called by any module. ! */ ! String name = targetClass.getName() + "$$InjectedInvoker"; ! if (targetClass.isHiddenClass()) { ! // use the original class name ! name = name.replace('/', '_'); ! } ! Class<?> invokerClass = new Lookup(targetClass) ! .makeHiddenClassDefiner(name, INJECTED_INVOKER_TEMPLATE) ! .defineClass(true); ! assert checkInjectedInvoker(targetClass, invokerClass); return IMPL_LOOKUP.findStatic(invokerClass, "invoke_V", INVOKER_MT); } catch (ReflectiveOperationException ex) { throw uncaughtException(ex); } }
*** 1254,1267 **** MethodVisitor mv = cw.visitMethod(ACC_STATIC, "invoke_V", "(Ljava/lang/invoke/MethodHandle;[Ljava/lang/Object;)Ljava/lang/Object;", null, null); - // Suppress invoker method in stack traces. - AnnotationVisitor av0 = mv.visitAnnotation(InvokerBytecodeGenerator.HIDDEN_SIG, true); - av0.visitEnd(); - mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ALOAD, 1); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/invoke/MethodHandle", "invokeExact", "([Ljava/lang/Object;)Ljava/lang/Object;", false); --- 1268,1277 ----
< prev index next >