Merge branch 'JDK-8374654' into JDK-8208752

This commit is contained in:
Liam Miller-Cushon 2026-01-19 10:53:18 +01:00
commit 1f803bcce1
2 changed files with 28 additions and 6 deletions

View File

@ -702,12 +702,14 @@ public class LambdaToMethod extends TreeTranslator {
String functionalInterfaceClass = classSig(targetType);
String functionalInterfaceMethodName = samSym.getSimpleName().toString();
String functionalInterfaceMethodSignature = typeSig(types.erasure(samSym.type));
Symbol baseMethod = types.overriddenObjectMethod(refSym.enclClass(), refSym);
if (baseMethod != null) {
// The implementation method is a java.lang.Object method, runtime will resolve this method to
// a java.lang.Object method, so do the same.
// This case can be removed if JDK-8172817 is fixed.
refSym = ((MethodSymbol) baseMethod).asHandle();
if (refSym.enclClass().isInterface()) {
Symbol baseMethod = types.overriddenObjectMethod(refSym.enclClass(), refSym);
if (baseMethod != null) {
// The implementation method is a java.lang.Object method, runtime will resolve this method to
// a java.lang.Object method, so do the same.
// This case can be removed if JDK-8172817 is fixed.
refSym = ((MethodSymbol) baseMethod).asHandle();
}
}
String implClass = classSig(types.erasure(refSym.owner.type));
String implMethodName = refSym.getQualifiedName().toString();

View File

@ -63,9 +63,15 @@ public class SerializableObjectMethodReferencesOnInterfaces {
R apply(T t);
}
enum E {
ONE
}
void f() throws Exception {
F<I1, Integer> f1 = I1::hashCode;
F<I2, Integer> f2 = I2::hashCode;
F<E, Integer> f3 = E::hashCode;
F<Object, Integer> f4 = Object::hashCode;
}
}
@ -93,6 +99,20 @@ public class SerializableObjectMethodReferencesOnInterfaces {
getImplClass java/lang/Object
getImplMethodSignature ()I
getInstantiatedMethodType (LSerializableObjectMethodReferencesOnInterfaces$Test$I2;)Ljava/lang/Integer;
getImplMethodKind 5
getFunctionalInterfaceClass SerializableObjectMethodReferencesOnInterfaces$Test$F
getFunctionalInterfaceMethodName apply
getFunctionalInterfaceMethodSignature (Ljava/lang/Object;)Ljava/lang/Object;
getImplClass java/lang/Enum
getImplMethodSignature ()I
getInstantiatedMethodType (LSerializableObjectMethodReferencesOnInterfaces$Test$E;)Ljava/lang/Integer;
getImplMethodKind 5
getFunctionalInterfaceClass SerializableObjectMethodReferencesOnInterfaces$Test$F
getFunctionalInterfaceMethodName apply
getFunctionalInterfaceMethodSignature (Ljava/lang/Object;)Ljava/lang/Object;
getImplClass java/lang/Object
getImplMethodSignature ()I
getInstantiatedMethodType (Ljava/lang/Object;)Ljava/lang/Integer;
""";
if (!actual.equals(expected)) {
throw new AssertionError(