RFR: 8337142: StackOverflowError in Types.containsTypeRecursive with deeply nested type hierarchy [v2]

Vicente Romero vromero at openjdk.org
Mon Nov 3 18:28:45 UTC 2025


On Mon, 3 Nov 2025 16:02:43 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java line 3901:
>> 
>>> 3899:             boolean sameTypeArguments(List<Type> ts, List<Type> ss) {
>>> 3900:                 while (ts.nonEmpty() && ss.nonEmpty()
>>> 3901:                         && exactTypeVisitor.visit(ts.head, ss.head)) {
>> 
>> You could delegate to `sameTypeComparator` here?
>
> Another possibility would be to declare an overloaded method to `isSameType` that takes a type argument comparator function. And maybe the default type argument comparator function is `containsTypeEquivalent` but then other clients could override that.

I went for the first option. There is a public version of `containsTypeEquivalent` that takes two lists as arguments. For the second variant I think we would need to add the lambda to that method. We can add another version of that method but I think the first option is cleaner

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28101#discussion_r2487453067


More information about the compiler-dev mailing list