Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-dev] Much improved support for sealed types - available on master/HEAD
  • From: "Sankaran, Srikanth" <srikanth.sankaran@xxxxxxxxxxxxx>
  • Date: Tue, 29 Oct 2024 06:06:14 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=advantest.com; dmarc=pass action=none header.from=advantest.com; dkim=pass header.d=advantest.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=j/ZXYSSh8iftRL+Hz7A9PuVkSBUAVkA+lVvLKlh8i48=; b=yjuX8Em2x4s10U8UuVM/5iE7gEAg3y26KliUPyK05D+ylXxES6oV64jnTCPjUSjpDwkYJUKZZgUEgjTAb3YFozAGFOihSDuxipzWmsdZ9AUF0i6ZhxHoxChi0UFQRe6QwpMtmGYngeYVsWY7Fo5u9L5V4wLohSdMU+aJksh3igSP9bA4Nje/T5AUqScB+RPSRpc2dNhuJRdip6+XkskYhfkqVJgwBhwwyyPLpi7s6ypkNAIyqUMWzOVeqkv0TZdmFI0gZgByeVhBbzYhVutmf/8TWcVN3avoIaHOGgYvgUG3oaSllsLuJIVD5LrS01/UeFesiRUu1XFlNFv+01AaWA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jrbM+DqYOvbNkusOZIC65y5qWhi0quJZwIsmw3PkQlQ8CYYuNSpOVxXEl5fSA1wGlUfkrxMKgl2xDO08Aga1YFeWQKStvq6Y40xoMQYDl9ssf5nPrNhcamgg12AYqJ5Bl+2SHAxcuTnSQkI+ji3Exk6i1BLquapd3vu/SWZM+m6Qd9XtfQovG46obDZ/ZWf0sDdWrYGEUs8JZYEWP9ZWxvd1yPbA/5EfULuNBcS/pL0nmvuraiBli80tHps3UEoEttVD1JOL1eYyMMwWRQqPFnlJTrrzHgY5lQzlhohLuKhjz6xFhghoXaNPEGxSrZtEOWRAYdcvLafXuOspvu2iCw==
  • Delivered-to: jdt-dev@xxxxxxxxxxx
  • List-archive: <https://www.eclipse.org/mailman/private/jdt-dev/>
  • List-help: <mailto:jdt-dev-request@eclipse.org?subject=help>
  • List-subscribe: <https://www.eclipse.org/mailman/listinfo/jdt-dev>, <mailto:jdt-dev-request@eclipse.org?subject=subscribe>
  • List-unsubscribe: <https://www.eclipse.org/mailman/options/jdt-dev>, <mailto:jdt-dev-request@eclipse.org?subject=unsubscribe>
  • Thread-index: Adspxwjo02Xt1upJRc2GIp5ROuRSjQ==
  • Thread-topic: Much improved support for sealed types - available on master/HEAD

Hello!

 

On behalf of the JDT compiler team, I am pleased to share that over the last several weeks we have been busy on a project to significantly overhaul, cleanup, address key gaps in implementation and to polish ECJ’s implementation of JEP 409 - Sealed Classes (https://openjdk.org/jeps/409) and how that integrates with JEP 441 - Pattern Matching for switch

 

This effort is now complete and has been integrated into master/HEAD and is available via the I-Builds from the Eclipse download sites.

 

As a part of this project,

 

·         Every line of code of the implementation was studied, mapping it back to the JLS and aligning ECJ’s behavior with the JLS and the reference compiler, rewriting significant portions in the process

·         Every clause of the JLS mentioning sealed types was studied and was black box tested and white box tested mapping it to the implementation

·         Every actionable issue concerning sealed types in the compiler area in both Github tracker and Bugzilla was resolved.

·         Many defects in compiling enhanced switches and switch expressions that intersect with sealed types are also addressed. In particular, switch exhaustiveness analysis has been thoroughly revamped fixing several problems.

 

This doesn’t mean we won’t run into defects in future 😉- but this does mean that we are on a firm footing to be able to rapidly respond to and resolve any incoming issues in these functionalities.

As a matter of fact, this mail is to alert interested parties to engage in early testing, so we can address any remaining issues before 4.34 ships – We need, welcome, and appreciate your involvement here!

 

For the curious and the cognoscenti, here is an extract of the tickets resolved on Sealed types relative to the initial implementation: Critical, normal, trivial; Big, medium, small; Good, bad, ugly!

 

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2108 :

     [Sealed classes] Inconsistent type hierarchy on sealed interface when used with other from different level in class hierarchy

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2093 :

     [sealed types] ECJ complains of cycles in hierarchy where none exists bug

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3122 :

     [Reconciler][Sealed types] Extra errors in editor that go away on file save

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3121 :

     [Sealed types] Regression in instanceof check for sealed generic classes

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3111 :

     [Sealed types] Discovery and wiring of implicitly permitted subtypes can be significantly simplified.

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3096 :

     [Switch][Sealed types] Bad static analysis with the old switch syntax + an exhaustive pattern matching on a sealed type throws a MatchException bug compiler

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3039 :

     [Sealed types] Broken program crashes the compiler

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3166 :

    [Sealed types][Enhanced Switch] Exhaustiveness in pattern matching switch is wrong

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3038 :

     [Sealed types] ParameterizedTypeBinding.permittedTypes() needs more rigor

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3035 :

     [switch][sealed types] ECJ fails to signal a completely dominated case arm

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3031 :

     [Switch][Sealed types] Incorrect exhaustiveness check leads to MatchException at runtime

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3009 :

     A sealed interface with generic causes IllegalStateException and nothing can be done then

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2722 :

     Switch pattern matching accepts invalid case

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2720 :

     [Sealed Types + Enhanced Switch] Incorrect diagnostic about switch not being exhaustive

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2719 :

     [Switch _expression_ + Sealed Types] Suspect diagnostic about switch _expression_ being inexhaustive

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2714 :

     [Sealed types + switch _expression_] Internal inconsistency warning at compile time and verify error at runtime

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2709 :

     [Sealed types] Disjointness behavior difference vis a vis javac

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2667 :

     [Sealed Types] Failure to cast an Object to a generic sealed interface type bug compiler regression

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2652 :

     [Sealed Types] Permits clause handling in grammar/parser is unnecessarily complicated

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2595 :

     [sealed types] ECJ accepts a cast from a disjoint interface to a sealed interface

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2574 :

     [Sealed types][selection] Can't navigate in files in 2nd level child

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2554 :

     [sealed types] ECJ should not accept type annotations on permitted types

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2540 :

     [Sealed types] Completion fails within the body of a permitted class regression

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2521 :

     NPE on exhaustive pattern matching switch expressions with sealed interface (Java 21, 3.19.500.v20240601-0610).

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2513 :

     [Enhanced switch] Unexpected MatchException thrown at runtime

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2508 :

     [Switch _expression_] Compiler erroneously treats guarded case patterns as covering switch selector type

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2503 :

     [Switch _expression_] Switching on sealed interface instance compiles even when the switch _expression_ does not cover all possible input values

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2146 :

     Incorrect "should be a permitted subtype" error if sealed type is an inner type of record

https://github.com/eclipse-jdt/eclipse.jdt.core/pull/3123 :

    Streamline error handling for sealed types

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1998 :

     [Sealed classes] Incorrect Reconciler error: The type A that implements a sealed interface I should be a permitted subtype of I

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1808 :

     [sealed-classes] Incorrect unused import warning

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1788 :

     Inference issue between the diamond syntax and pattern matching (switch on objects)

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1735 :

     [Sealed types][Switch] Pattern switch - ECJ accepts code rejected by javac

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1725 :

     [21] Wrongly needing a default case for a switch _expression_

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/581 :

     Sealed classes permits clause­­­­­­­­­­­­­­­­

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/62 :

     [Reconciler][Sealed types] Inconsistent type hierarchy with sealed classes compiler

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3144 :

     [Sealed types] Diagnostic can be more direct when a @FunctionalInterface is declared sealed

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3100 :

     [Sealed types] Duplicate diagnostics for illegal modifier combination

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3007 :

     [Sealed types] Extra and spurious error messages with faulty type sealing

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2708 :

     Error in JDT Core during AST creation when using exhaustive switch statement and @NotNull

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2707 :

     [Sealed types] ECJ allows a class to be declared as both sealed and non-sealed

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2672 :

     [Sealed Types] Strange error from ECJ: Syntax error on token "permits", permits expected

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2654 :

     [Sealed Types] Compiler does not handle non-sealed contextual keyword correctly

https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2017 :

     [Patterns][internal] toString() output of AST nodes shows up with modifier sealed for pattern variables    

https://bugs.eclipse.org/bugs/show_bug.cgi?id=576378 :

    [compiler] Wrong rawtype warning and wrong compilation of generic type reference in permits clause

https://bugs.eclipse.org/bugs/show_bug.cgi?id=576471 :

    Sealed type hierarchy doesn't compile if there are redundant type references

https://bugs.eclipse.org/bugs/show_bug.cgi?id=577787 :

    [17] False positive error for explicitly permitted class extending a sealed class

https://bugs.eclipse.org/bugs/show_bug.cgi?id=577872 :

   [17] Incremental builder problems with sealed types: Bogus error: The type C that implements a sealed interface Types.B should be a permitted subtype of Types.B

https://bugs.eclipse.org/bugs/show_bug.cgi?id=565234 :

    [15] An exception occurred while getting the Javadoc for permit class

https://bugs.eclipse.org/bugs/show_bug.cgi?id=574573 :

    [17] Invalid warning for parameterized sealed type

https://bugs.eclipse.org/bugs/show_bug.cgi?id=575388 :

    [16] Hover on case shows sealed value while debugging

https://bugs.eclipse.org/bugs/show_bug.cgi?id=576374 :

    Switch pattern matching exhaustiveness check false positive

https://bugs.eclipse.org/bugs/show_bug.cgi?id=576471 :

    Sealed type hierarchy doesn't compile if there are redundant type references

https://bugs.eclipse.org/bugs/show_bug.cgi?id=574943 :

    [17][compiler][sealed] Incorrect compile error when sealed class tries to permit an interface

 

Thanks and regards,

Srikanth

 


Back to the top