RFR: 8343306: javac is failing to determine disjoint-ness between a class and a sealed interface
Maurizio Cimadamore
mcimadamore at openjdk.org
Thu Oct 31 14:01:35 UTC 2024
On Thu, 31 Oct 2024 13:49:40 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java line 1694:
>>
>>> 1692: } else {
>>> 1693: if (csym.isFinal()) {
>>> 1694: return true;
>>
>> Maybe add a comment e.g. `not freely extensible`
>
> Strike that - freely extensible is checked later. Seems to me that this `csym.isFinal()` check is subsumed by the new `isClassFreelyExtensible` predicate (and so, can be removed) ?
Question: I find it hard to verify that this logic matches the spec exactly. That's because the spec says when under which conditions two types are disjoint, while this code seems to work the other way around -- e.g. find ways to say when two types are NOT disjoint. Also, the code tries to share some logic across different paths - which also makes thing harder to check.
Would it be possible to write the code the other way around and align it fully with the spec?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21794#discussion_r1824520801
More information about the compiler-dev
mailing list