diff --git a/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisMethod.java b/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisMethod.java index 6f96b0435844..80c282cd16d5 100644 --- a/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisMethod.java +++ b/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisMethod.java @@ -389,12 +389,14 @@ private void processMethodOverrides() { declaringClass.forAllSuperTypes(superType -> { /* * Iterate all the super types (including this type itself) looking for installed - * override notifications. If this method resolves in a super type, and it has an + * override notifications. If this method is found in a super type, and it has an * override handler installed in that type, pass this method to the callback. It * doesn't matter if the superMethod is actually reachable, only if it has any - * override handlers installed. + * override handlers installed. Note that ResolvedJavaType.resolveMethod() cannot be + * used here because it only resolves methods declared by the type itself or if the + * method's declaring class is assignable from the type. */ - AnalysisMethod superMethod = resolveInType(superType); + AnalysisMethod superMethod = findInType(superType); if (superMethod != null) { superMethod.notifyMethodOverride(AnalysisMethod.this); } @@ -402,6 +404,16 @@ private void processMethodOverrides() { } } + /** Find if the type declares a method with the same name and signature as this method. */ + private AnalysisMethod findInType(AnalysisType type) { + try { + return type.findMethod(wrapped.getName(), getSignature()); + } catch (UnsupportedFeatureException | LinkageError e) { + /* Ignore linking errors and deleted methods. */ + return null; + } + } + protected void notifyMethodOverride(AnalysisMethod override) { declaringClass.getOverrideReachabilityNotifications(this).forEach(n -> n.notifyCallback(getUniverse(), override)); } diff --git a/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisType.java b/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisType.java index ded0243b010d..520b22f91892 100644 --- a/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisType.java +++ b/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisType.java @@ -640,6 +640,9 @@ protected void forAllSuperTypes(Consumer superTypeConsumer, boolea if (dimension > 0 && !elementalType.isPrimitive() && !elementalType.isJavaLangObject()) { forAllSuperTypes(universe.objectType(), dimension, true, superTypeConsumer); } + if (this.isInterface()) { + superTypeConsumer.accept(universe.objectType()); + } } private static void forAllSuperTypes(AnalysisType elementType, int arrayDimension, boolean processType, Consumer superTypeConsumer) {