Skip to content

Commit a1e1789

Browse files
committed
[GR-44282] [GR-44568] Fix reachability handlers.
PullRequest: graal/13973
2 parents 07fac34 + 7598447 commit a1e1789

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisMethod.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,19 +473,31 @@ private void processMethodOverrides() {
473473
declaringClass.forAllSuperTypes(superType -> {
474474
/*
475475
* Iterate all the super types (including this type itself) looking for installed
476-
* override notifications. If this method resolves in a super type, and it has an
476+
* override notifications. If this method is found in a super type, and it has an
477477
* override handler installed in that type, pass this method to the callback. It
478478
* doesn't matter if the superMethod is actually reachable, only if it has any
479-
* override handlers installed.
479+
* override handlers installed. Note that ResolvedJavaType.resolveMethod() cannot be
480+
* used here because it only resolves methods declared by the type itself or if the
481+
* method's declaring class is assignable from the type.
480482
*/
481-
AnalysisMethod superMethod = resolveInType(superType);
483+
AnalysisMethod superMethod = findInType(superType);
482484
if (superMethod != null) {
483485
superMethod.notifyMethodOverride(AnalysisMethod.this);
484486
}
485487
});
486488
}
487489
}
488490

491+
/** Find if the type declares a method with the same name and signature as this method. */
492+
private AnalysisMethod findInType(AnalysisType type) {
493+
try {
494+
return type.findMethod(wrapped.getName(), getSignature());
495+
} catch (UnsupportedFeatureException | LinkageError e) {
496+
/* Ignore linking errors and deleted methods. */
497+
return null;
498+
}
499+
}
500+
489501
protected void notifyMethodOverride(AnalysisMethod override) {
490502
declaringClass.getOverrideReachabilityNotifications(this).forEach(n -> n.notifyCallback(getUniverse(), override));
491503
}

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisType.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,9 @@ protected void forAllSuperTypes(Consumer<AnalysisType> superTypeConsumer, boolea
654654
if (dimension > 0 && !elementalType.isPrimitive() && !elementalType.isJavaLangObject()) {
655655
forAllSuperTypes(universe.objectType(), dimension, true, superTypeConsumer);
656656
}
657+
if (this.isInterface()) {
658+
superTypeConsumer.accept(universe.objectType());
659+
}
657660
}
658661

659662
private static void forAllSuperTypes(AnalysisType elementType, int arrayDimension, boolean processType, Consumer<AnalysisType> superTypeConsumer) {

0 commit comments

Comments
 (0)