8006179: JSR292 MethodHandles lookup with interface using findVirtual()
authorvlivanov
Fri, 22 Feb 2013 03:00:12 -0800
changeset 16119 ca09c1ad6a45
parent 16118 9f3390f42157
child 16120 133a029f510a
8006179: JSR292 MethodHandles lookup with interface using findVirtual() Reviewed-by: jrose, twisti
jdk/src/share/classes/java/lang/invoke/DirectMethodHandle.java
--- a/jdk/src/share/classes/java/lang/invoke/DirectMethodHandle.java	Fri Feb 22 03:00:48 2013 -0800
+++ b/jdk/src/share/classes/java/lang/invoke/DirectMethodHandle.java	Fri Feb 22 03:00:12 2013 -0800
@@ -51,6 +51,16 @@
     private DirectMethodHandle(MethodType mtype, LambdaForm form, MemberName member) {
         super(mtype, form);
         if (!member.isResolved())  throw new InternalError();
+
+        if (member.getDeclaringClass().isInterface() && !member.isAbstract()) {
+            // Check for corner case: invokeinterface of Object method
+            MemberName m = new MemberName(Object.class, member.getName(), member.getMethodType(), member.getReferenceKind());
+            m = MemberName.getFactory().resolveOrNull(m.getReferenceKind(), m, null);
+            if (m != null && m.isPublic()) {
+                member = m;
+            }
+        }
+
         this.member = member;
     }