Jorge Turbica / blog · Blog ← All articles ES · Leer en español
Languages

Java pulls Primitive Patterns after five previews and drops it from JDK 28

OpenJDK drops primitive type patterns because of Valhalla: if you use them with --enable-preview, your code won’t compile on JDK 28.

Five previews, from JDK 23 to JDK 27, and there won't be a sixth. On November 9, 2026, Project Amber announced it is stopping work on Primitive Types in Patterns, instanceof, and switch: the draft JEP for a sixth preview is being withdrawn and the feature is removed from JDK 28, even with --enable-preview. Pulling a preview feature is rare, and the reason says a lot about where the language is heading.

What goes away

The feature brought pattern matching to primitive types. It let you write case int i when i >= 100 in a switch, use instanceof with int or double, and deconstruct a record with a primitive type other than its component's. The JEP's own example is a JsonNumber(double d): with the preview, instanceof JsonNumber(int a) only matched if the double fit into an int without losing information. Without it, you're back to a manual cast that can silently truncate.

That idea of exact conversion was the best part of the design: the pattern tells lossy and lossless conversions apart and simply doesn't match when information would be lost.

ReleaseJEPStatus
JDK 23JEP 455First preview
JDK 24JEP 488Second, unchanged
JDK 25JEP 507Third, unchanged
JDK 26JEP 530Fourth, stricter exactness and dominance
JDK 27JEP 532Fifth, unchanged
JDK 28—Removed

Why it's being pulled

It's not that the feature didn't work. The reason is Valhalla: that project is exploring a new vision for numerics in Java, including user-defined numeric types. Those new types would have to support exact conversion, and exact conversion would have to account for them. With Valhalla still evolving, the team considers it premature to lock in the current definition. Finalizing it now would mean committing to semantics that may not fit the numbers of the future.

The process allows for this without drama: JEP 12, which governs preview features, already anticipates that one can be removed through a JBS issue, with no new JEP required.

What comes next

Amber plans to replace it with a different feature, Constant Patterns, which carries over part of the work, such as the expanded primitive support in switch. It will let some constants act as nested patterns inside a record, e.g. case Point(0, 0), removing when clauses from a lot of switch blocks. A draft JEP is due shortly.

Who's affected

Almost nobody in production, because preview features shouldn't be there. But anyone who tried it in internal projects, or in libraries that build with --enable-preview on every release, will see that code stop compiling on JDK 28. If that's you, the fix is mechanical: case int i goes back to default, and primitive patterns inside records go back to a cast with your own range check.

java
// JDK 27 with --enable-preview
case int i when i >= 100 -> issueGoldCard();
case int i -> standardOffer(i);

// JDK 28: no primitive patterns
default -> flights >= 100 ? issueGoldCard() : standardOffer(flights);

The takeaway goes beyond this one feature: five previews don't guarantee something becomes standard. Previews exist precisely so the language can change its mind, and Java has just used that door on a feature that had been in plain sight for five releases.

Sources

Jorge Turbica

Software Engineer and SRE. I write about the real challenges I run into in production.

See portfolio ↗