From fccc7742a66efe0a52f91c5555a4cb22b501a69a Mon Sep 17 00:00:00 2001 From: Codrut Stancu Date: Wed, 8 Mar 2023 13:12:55 +0100 Subject: [PATCH 1/2] Fix looking-up super methods with installed override handlers. (cherry picked from commit 27a631b60ba23862349a00c1a1b85e6683c75560) --- .../graal/pointsto/meta/AnalysisMethod.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) 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)); } From 1cdb82282caf28bb6fc1040d67a8aa28cb20eca9 Mon Sep 17 00:00:00 2001 From: Codrut Stancu Date: Tue, 7 Mar 2023 20:03:18 +0100 Subject: [PATCH 2/2] Process Object as an interface super-type. (cherry picked from commit 759844717a7f3d53eebc0404fc3e8d13e5dc848a) --- .../src/com/oracle/graal/pointsto/meta/AnalysisType.java | 3 +++ 1 file changed, 3 insertions(+) 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) {