On Fri, 20 Nov 2026 14:09:00 GMT, Aggelos Biboudis <[email protected]> 
wrote:

>> Removes the preview implementation of Primitive Types in Patterns, 
>> `instanceof`, and `switch` from JDK 28. The withdrawn feature is rejected 
>> even with `--enable-preview`. 
>> 
>> The compiler changes restore the pre-preview rules while preserving 
>> subsequent fixes (listed on the CSR). JShell, diagnostics, and affected 
>> regression tests are updated accordingly.
>> 
>> I would like to explicitely mention the two components described on the CSR 
>> (for symmetry):
>> 
>> 1. `SwitchBootstraps.typeSwitch` no longer performs exact numeric 
>> conversions or accepts `Long`, `Float`, `Double`, or `Boolean` constant 
>> labels. It also rejects `void.class` labels. Primitive selector descriptors 
>> and primitive class labels remain accepted through boxing and matching via 
>> their wrapper classs, preserving compatibility with non-preview 
>> record-pattern binaries generated by JDK 23-27. I documented this in the 
>> JavaDoc of `typeSwitch` as well. This behavior is tested anew in 
>> `SwitchBootstrapsTest::testPrimitiveTypeCompatibility` and 
>> `NoPrimitivesAsCaseLabelsFor21::findPrimitiveBootstrapArguments`.
>> 
>> 1. `ExactConversionsSupport` and all its public methods are retained; 
>> references to the withdrawn preview specification are removed.
>> 
>> Since this removal is not merely a `git revert`. The removal preserves the 
>> fixes. The restored rules are adapted to the current compiler. No 
>> functionality should be lost.
>> 
>> Among the tests there is a new one `PrimitivePatternsRemoved` covering all 
>> eight primitive types, extended `instanceof` forms. It runs with preview 
>> disabled and enabled, and with `--release 21` and `22`. 
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Aggelos Biboudis has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Address review

@mcimadamore Following your suggestions, I refactored slightly the code taking 
inspiration from the structure used for PP. It captures that restricted set of 
unconditionality rules in [JLS ยง14.30.3, Properties of 
Patterns](https://docs.oracle.com/javase/specs/jls/se27/html/jls-14.html#jls-14.30.3),
 with erasure and boxing kept explicit at the call sites.

Now, we could also reuse it in 
[Check.checkSwitchCaseLabelDominated](https://github.com/openjdk/jdk/blob/d73128aed75ccd6127ea3a94930ec50b40f366c9/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java#L4884)
 and 
[Attr.checkCastablePattern](https://github.com/openjdk/jdk/blob/d73128aed75ccd6127ea3a94930ec50b40f366c9/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java#L4210)
 but I kept the refactoring limited to the current call sites. What do you 
think?

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

PR Comment: https://git.openjdk.org/jdk/pull/33919#issuecomment-7043975090

Reply via email to