Skip to content

Commit 0261fc4

Browse files
committed
[GR-34003] Fix reflection for shadowed methods
PullRequest: graal/10086
2 parents 367ee6c + 3924ae6 commit 0261fc4

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/hosted/ReflectionDataBuilder.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -270,27 +270,24 @@ protected void processMethodMetadata(DuringAnalysisAccessImpl access) {
270270
}
271271
}
272272

273-
private static final Map<AnalysisMethod, Set<AnalysisType>> seenHiddenMethods = new HashMap<>();
273+
private final Map<AnalysisMethod, Set<AnalysisType>> seenHiddenMethods = new HashMap<>();
274274

275275
private void registerHiddenSubTypeMethods(AnalysisMethod method, AnalysisType type) {
276-
if (seenHiddenMethods.containsKey(method) && seenHiddenMethods.get(method).contains(type)) {
277-
return;
278-
}
279-
seenHiddenMethods.computeIfAbsent(method, m -> new HashSet<>()).add(type);
280276

281277
if (!type.equals(method.getDeclaringClass()) && type.isReachable()) {
282-
try {
283-
AnalysisMethod subClassMethod = type.findMethod(method.getName(), method.getSignature());
284-
if (subClassMethod != null) {
285-
hiddenMethods.add(subClassMethod);
286-
/* This method shadows all of its subclasses */
287-
return;
278+
if (!seenHiddenMethods.containsKey(method) || !seenHiddenMethods.get(method).contains(type)) {
279+
seenHiddenMethods.computeIfAbsent(method, m -> new HashSet<>()).add(type);
280+
try {
281+
AnalysisMethod subClassMethod = type.findMethod(method.getName(), method.getSignature());
282+
if (subClassMethod != null) {
283+
hiddenMethods.add(subClassMethod);
284+
}
285+
} catch (UnsupportedFeatureException | LinkageError e) {
286+
/*
287+
* A method that is not supposed to end up in the image is considered as being
288+
* absent for reflection purposes.
289+
*/
288290
}
289-
} catch (UnsupportedFeatureException | LinkageError e) {
290-
/*
291-
* A method that is not supposed to end up in the image is considered as being
292-
* absent for reflection purposes.
293-
*/
294291
}
295292
}
296293
for (AnalysisType subType : type.getSubTypes()) {

0 commit comments

Comments
 (0)