RFR: 8303374: Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) [v42]

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Jan 24 12:43:36 UTC 2024


On Wed, 24 Jan 2024 11:53:52 GMT, Aggelos Biboudis <abimpoudis at openjdk.org> wrote:

>> This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview).
>> 
>> Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/
>
> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Set previewEnabled properly in SwitchBootstraps

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java line 2962:

> 2960:      * More rewritings:
> 2961:      *
> 2962:      * - If the `instanceof` check is unconditionally exact rewrite to true.

Note: the same effect can be obtained, w/o rewriting (and perhaps more simply) by detecting the case of an unconditionally exact "instanceof" test, and giving the instanceof expression a constant boolean type (with value "true"). This can be done in Attr. Then, `Gen` will shortcircuit the expression, as required.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1464857684


More information about the core-libs-dev mailing list