RFR: 8319987: compilation of sealed classes leads to infinite recursion
Vicente Romero
vromero at openjdk.org
Wed Nov 15 15:45:35 UTC 2023
On Wed, 15 Nov 2023 15:26:42 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:
>> The compiler can throw a SOE when trying to compile an incorrect sealed classes hierarchy like:
>>
>> sealed interface Action permits Add {}
>> sealed interface MathOp permits Add {}
>> sealed static class Add implements MathOp permits Add {}
>>
>> The error is thrown while trying to prove if two classes are disjoint or not. The proposed solution is to keep a set with the pairs of classes analyzed so far and stop as soon as a the current pair of classes is already in the set.
>>
>> TIA
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java line 1684:
>
>> 1682: } else {
>> 1683: pairsSeen.add(newPair);
>> 1684: }
>
> Minor simplification possible here:
>
> if (!pairsSeen.add(newPair))
> return;
sure I like it thanks!
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16668#discussion_r1394390842
More information about the compiler-dev
mailing list