mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-09 14:38:42 +00:00
8374654: Inconsistent handling of lambda deserialization for Object method references on interfaces
This commit is contained in:
parent
629bf20f59
commit
e3bb33ed42
@ -2858,13 +2858,17 @@ public class Types {
|
||||
hasSameArgs(t, erasure(s)) || hasSameArgs(erasure(t), s);
|
||||
}
|
||||
|
||||
public boolean overridesObjectMethod(TypeSymbol origin, Symbol msym) {
|
||||
public Symbol overriddenObjectMethod(TypeSymbol origin, Symbol msym) {
|
||||
for (Symbol sym : syms.objectType.tsym.members().getSymbolsByName(msym.name)) {
|
||||
if (msym.overrides(sym, origin, Types.this, true)) {
|
||||
return true;
|
||||
return sym;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean overridesObjectMethod(TypeSymbol origin, Symbol msym) {
|
||||
return overriddenObjectMethod(origin, msym) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -702,13 +702,12 @@ public class LambdaToMethod extends TreeTranslator {
|
||||
String functionalInterfaceClass = classSig(targetType);
|
||||
String functionalInterfaceMethodName = samSym.getSimpleName().toString();
|
||||
String functionalInterfaceMethodSignature = typeSig(types.erasure(samSym.type));
|
||||
Symbol baseMethod = refSym.baseSymbol();
|
||||
Symbol origMethod = baseMethod.baseSymbol();
|
||||
if (baseMethod != origMethod && origMethod.owner == syms.objectType.tsym) {
|
||||
//the implementation method is a java.lang.Object method transferred to an
|
||||
//interface that does not declare it. Runtime will refer to this method as to
|
||||
//a java.lang.Object method, so do the same:
|
||||
refSym = ((MethodSymbol) origMethod).asHandle();
|
||||
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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user