8006179: JSR292 MethodHandles lookup with interface using findVirtual()
Reviewed-by: jrose, twisti
--- 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;
}