29
29
import java .lang .reflect .Modifier ;
30
30
import java .util .Arrays ;
31
31
import java .util .List ;
32
+ import java .util .concurrent .ConcurrentHashMap ;
32
33
import java .util .stream .Stream ;
33
34
34
35
import com .oracle .graal .pointsto .ClassInclusionPolicy ;
60
61
import jdk .vm .ci .code .BytecodePosition ;
61
62
import jdk .vm .ci .meta .ConstantReflectionProvider ;
62
63
import jdk .vm .ci .meta .ResolvedJavaType ;
64
+ import jdk .vm .ci .meta .Signature ;
63
65
64
66
public class NativeImagePointsToAnalysis extends PointsToAnalysis implements Inflation {
65
67
@@ -68,6 +70,14 @@ public class NativeImagePointsToAnalysis extends PointsToAnalysis implements Inf
68
70
private final CustomTypeFieldHandler customTypeFieldHandler ;
69
71
private final CallChecker callChecker ;
70
72
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
+
71
81
@ SuppressWarnings ("this-escape" )
72
82
public NativeImagePointsToAnalysis (OptionValues options , AnalysisUniverse universe ,
73
83
AnalysisMetaAccess metaAccess , SnippetReflectionProvider snippetReflectionProvider ,
@@ -206,7 +216,10 @@ public AnalysisMethod fallbackResolveConcreteMethod(AnalysisType resolvingType,
206
216
*/
207
217
return method ;
208
218
}
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 );
210
223
}
211
224
return super .fallbackResolveConcreteMethod (resolvingType , method );
212
225
}
0 commit comments