RFR: 8343306: javac is failing to determine if a class and a sealed interface are disjoint [v6]
Maurizio Cimadamore
mcimadamore at openjdk.org
Thu Nov 7 17:41:44 UTC 2024
On Thu, 7 Nov 2024 15:35:50 GMT, Vicente Romero <vromero at openjdk.org> wrote:
>> src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java line 1697:
>>
>>> 1695: } else if (csym.isSealed()) {
>>> 1696: return areDisjoint(isym, csym.getPermittedSubclasses());
>>> 1697: } else if (isym.isSealed()) {
>>
>> where did the freely extensible check go? That part is in the spec, but there's no code for it?
>
> @mcimadamore I can add a comment in this section of the code that refers to why we think that the current checks cover the reference in the spec to freely extensible class
But, according to the spec, if I have:
sealed class Sup { }
non-sealed class Sub extends Sup { }
Then `Sub` is not freely extensible. Becaus, even though it is neither `sealed` nor `final`, its direct superclass is `sealed`. I agree that, in spirit, `Sub` can be extended, but that's not what the JLS seems to say?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21794#discussion_r1833113029
More information about the compiler-dev
mailing list