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 9b8c5a908fd4..8bb480331d49 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 @@ -473,12 +473,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); } @@ -486,6 +488,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 f30324feebc9..c6d00d6f4e2d 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 @@ -654,6 +654,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) {