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 18:02:48 UTC 2024
On Thu, 7 Nov 2024 17:51:15 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
>> 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?
>
> I believe the spec says it is freely extensible: a class which has a sealed direct super class or super interface is freely extensible iff the is non-sealed. Maybe I am missing something?
> https://docs.oracle.com/javase/specs/jls/se22/html/jls-8.html#jls-8.1.1.2
Ah, missed this:
A class that has a sealed direct superclass or a sealed direct superinterface is freely extensible if and only if it is declared non-sealed.
```
Both statements, coupled together seem a very roundabout way to do roughly what the new code is doing. I will investigate as to why this form was preferred, to make sure we're not missing anything.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21794#discussion_r1833137678
More information about the compiler-dev
mailing list