RFR: 8343306: javac is failing to determine if a class and a sealed interface are disjoint [v6]
Jan Lahoda
jlahoda at openjdk.org
Thu Nov 7 17:53:44 UTC 2024
On Thu, 7 Nov 2024 17:39:22 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> @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?
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
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21794#discussion_r1833127794
More information about the compiler-dev
mailing list