From 3e6e13dece376d65db858c5e6ee833107fb64841 Mon Sep 17 00:00:00 2001 From: Shilpi Rastogi Date: Tue, 29 Nov 2016 01:06:10 -0800 Subject: [PATCH] 8133719: java.lang.InternalError in java.lang.invoke.MethodHandleImpl$BindCaller.bindCaller Reviewed-by: psandoz --- .../share/classes/java/lang/invoke/MethodHandleImpl.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java index 05ef3c983f0..010b61809ee 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java @@ -1147,12 +1147,14 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; static MethodHandle bindCaller(MethodHandle mh, Class hostClass) { - // Do not use this function to inject calls into system classes. + // Code in the the boot layer should now be careful while creating method handles or + // functional interface instances created from method references to @CallerSensitive methods, + // it needs to be ensured the handles or interface instances are kept safe and are not passed + // from the boot layer to untrusted code. if (hostClass == null || (hostClass.isArray() || hostClass.isPrimitive() || - hostClass.getName().startsWith("java.") || - hostClass.getName().startsWith("sun."))) { + hostClass.getName().startsWith("java.lang.invoke."))) { throw new InternalError(); // does not happen, and should not anyway } // For simplicity, convert mh to a varargs-like method.