On Thu, 19 Nov 2026 14:59:22 GMT, Maurizio Cimadamore <[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). > > src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java line 4913: > >> 4911: Type existingPatternType = >> types.erasure(existingPattern.type); >> 4912: Type currentPatternType = >> types.erasure(currentPattern.type); >> 4913: if (existingPatternType.isPrimitive() ^ >> currentPatternType.isPrimitive()) { > > replace `^` with `!=` ? There's others too... ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/33919#discussion_r4630617378
