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:15:45 UTC 2024


On Thu, 7 Nov 2024 17:59:23 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> 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.

Ok, this seems to be mostly a spec thing. We do have declarations (like records) that are not freely extensible, but do not need `final` or `sealed`. I suppose this is not a problem for javac because javac adds `final` to records and enums.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21794#discussion_r1833152748


More information about the compiler-dev mailing list