changeset 5602:4bb16e8e663a

8006179: JSR292 MethodHandles lookup with interface using findVirtual() Reviewed-by: twisti
author jrose
date Fri, 18 Jan 2013 20:47:51 -0800
parents 33b30ad16898
children 6b6c1d66f161
files src/share/classes/java/lang/invoke/DirectMethodHandle.java
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/lang/invoke/DirectMethodHandle.java	Thu Jan 24 10:51:48 2013 -0800
+++ b/src/share/classes/java/lang/invoke/DirectMethodHandle.java	Fri Jan 18 20:47:51 2013 -0800
@@ -44,6 +44,15 @@
         if (!m.isResolved())
             throw new InternalError();
 
+        if (m.getDeclaringClass().isInterface() && !m.isAbstract()) {
+            // Check for corner case: invokeinterface of Object method.
+            MemberName m2 = new MemberName(Object.class, m.getName(), m.getMethodType(), m.getModifiers());
+            m2 = MemberName.getFactory().resolveOrNull(m2, false, null);
+            if (m2 != null && m2.isPublic()) {
+                m = m2;
+            }
+        }
+
         MethodHandleNatives.init(this, (Object) m, doDispatch, lookupClass);
     }