Skip to content

Commit b71d33d

Browse files
committed
track fallback methods created within fallbackResolveConcreteMethod.
1 parent 5e122eb commit b71d33d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/analysis/NativeImagePointsToAnalysis.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.lang.reflect.Modifier;
3030
import java.util.Arrays;
3131
import java.util.List;
32+
import java.util.concurrent.ConcurrentHashMap;
3233
import java.util.stream.Stream;
3334

3435
import com.oracle.graal.pointsto.ClassInclusionPolicy;
@@ -60,6 +61,7 @@
6061
import jdk.vm.ci.code.BytecodePosition;
6162
import jdk.vm.ci.meta.ConstantReflectionProvider;
6263
import jdk.vm.ci.meta.ResolvedJavaType;
64+
import jdk.vm.ci.meta.Signature;
6365

6466
public class NativeImagePointsToAnalysis extends PointsToAnalysis implements Inflation {
6567

@@ -68,6 +70,14 @@ public class NativeImagePointsToAnalysis extends PointsToAnalysis implements Inf
6870
private final CustomTypeFieldHandler customTypeFieldHandler;
6971
private final CallChecker callChecker;
7072

73+
/**
74+
* Track the fallback methods created so that they are unique.
75+
*/
76+
private final ConcurrentHashMap<FallbackDescriptor, IncompatibleClassChangeFallbackMethod> fallbackMethods = new ConcurrentHashMap<>();
77+
78+
record FallbackDescriptor(AnalysisType resolvingType, String name, Signature signature) {
79+
}
80+
7181
@SuppressWarnings("this-escape")
7282
public NativeImagePointsToAnalysis(OptionValues options, AnalysisUniverse universe,
7383
AnalysisMetaAccess metaAccess, SnippetReflectionProvider snippetReflectionProvider,
@@ -206,7 +216,10 @@ public AnalysisMethod fallbackResolveConcreteMethod(AnalysisType resolvingType,
206216
*/
207217
return method;
208218
}
209-
return getUniverse().lookup(new IncompatibleClassChangeFallbackMethod(resolvingType.getWrapped(), method.getWrapped(), findResolutionError(resolvingType, method.getJavaMethod())));
219+
220+
var uniqueFallbackMethod = fallbackMethods.computeIfAbsent(new FallbackDescriptor(resolvingType, method.getName(), method.getSignature()),
221+
(k) -> new IncompatibleClassChangeFallbackMethod(resolvingType.getWrapped(), method.getWrapped(), findResolutionError(resolvingType, method.getJavaMethod())));
222+
return getUniverse().lookup(uniqueFallbackMethod);
210223
}
211224
return super.fallbackResolveConcreteMethod(resolvingType, method);
212225
}

0 commit comments

Comments
 (0)