Preview, incubator, removed
Structured concurrency is still preview on Java 25, and the Java 21 code does not compile there. That is what "may change" means.
Java ships every six months, and not everything in a release is finished. Four words decide whether you may build on something, and getting them wrong is how a service ends up pinned to a JDK nobody wants to maintain.
The four states
| State | What it means | May you use it in production? |
|---|---|---|
| GA | final, and covered by the compatibility promise | yes |
| Preview | complete but not final; may change or disappear | no |
| Incubator | an API not yet even a preview; a separate module | no |
| Deprecated | still works, marked for removal | yes, and plan to stop |
| Removed | gone | it will not compile |
A preview feature is off by default, and turning it on is deliberately awkward. You need --enable-preview at compile time and at run time, and the class files are stamped with the JDK version that produced them — so a class compiled with preview on Java 21 will not run on Java 22 at all, even with preview enabled. That is not an oversight; it is the mechanism that stops preview code spreading.
What "may change" actually means
Structured concurrency arrived as a preview in Java 21. Here is that Java 21 code, on Java 25:
try (var scope = new StructuredTaskScope.ShutdownOnFailure()) {
scope.fork(() -> 1);
scope.join();
}Prev.java:4: error: StructuredTaskScope is a preview API and is disabled by default.
(use --enable-preview to enable preview APIs)So it is still preview on Java 25 — four releases and an LTS later. And with --enable-preview turned on:
Prev.java:4: error: cannot find symbol
try (var scope = new StructuredTaskScope.ShutdownOnFailure()) {
^
symbol: class ShutdownOnFailure
location: interface StructuredTaskScopeRead the last line. In Java 21 StructuredTaskScope was a class with a nested ShutdownOnFailure. In Java 25 it is an interface, and that nested class is gone. The code does not compile even with preview enabled.
That is the whole lesson in one error message: preview means the API can change shape, and it did. A team that built on it in 21 has a rewrite, not an upgrade.
Where preview is worth using: a spike, a benchmark, a prototype you will throw away, and feedback — which is the point of the mechanism. The JDK team ships previews to find out what is wrong with them, and that only works if people try them somewhere disposable.
Incubator is one step earlier
An incubator module is an API that is not yet ready to be a preview. It lives in a module named jdk.incubator.something, and using it needs --add-modules.
The vector API has been in incubation since Java 16 and is still there. That is the honest signal about timelines: incubator means years, not releases.
Deprecated, and the two kinds
Java deprecates far more than it removes, and the annotation now carries the distinction:
@Deprecated(since = "9", forRemoval = true)forRemoval = falseis advisory.Date's constructors have been deprecated since 1997 and still work. You should move; nothing is forcing you.forRemoval = trueis a countdown.Thread.stopwent this way and is now gone; the finalization mechanism is on the same path.
The practical habit: compile with -Xlint:deprecation and read the output. A forRemoval = true warning is a future build failure with a date nobody has told you.
What has actually been removed
Removals are rare and they cluster around a few upgrades, which is why the upgrading lesson treats them as the main event:
- Java 11 removed the Java EE and CORBA modules — JAXB, JAX-WS,
javax.annotation. This is the most common Java 8 → 11 break, and the fix is adding the artifacts as ordinary dependencies, because they now live on Maven Central rather than in the JDK. - Java 17 deprecated the Security Manager for removal (JEP 411; Java 24 permanently disabled it, JEP 486) and removed the experimental AOT and JIT compiler (JEP 410).
- Java 21 deprecated the 32-bit Windows port for removal (JEP 449); Java 24 removed it (JEP 479).
Almost everything else is deprecation without removal, which is why Java's compatibility reputation is deserved even though the release cadence sounds alarming.
Reading a JEP
Every feature arrives as a JEP with a status line, and it is the fastest way to answer "can I use this":
- Status: Draft, Candidate, Integrated, Closed/Delivered.
- Release: which version it landed in.
- Whether the delivery says preview, second preview, incubator or nothing.
"Second preview" is a useful signal in both directions: the feature is being taken seriously, and it changed since the first one.
Under the hood: how the JDK actually stops preview code from spreading
"Off by default and awkward to turn on" above is not a policy enforced by convention — it is enforced by a bit in the class file. When javac --enable-preview compiles a class using a preview feature, it sets the minor version field of the class file to 0xFFFF. Every other class file the JDK ever produces has minor version 0; this value exists for exactly one purpose, and the JVM's class-file verifier checks it on every class it loads: a class file with minor version 0xFFFF is only accepted by a JVM running the exact same major version it was compiled for, and only when that JVM is also launched with --enable-preview. Mismatch either condition — a different JDK version, or preview not re-enabled at run time — and loading fails with class file has wrong version or a preview-specific variant of it, before your code runs at all.
That is the mechanism behind the lesson's claim that Java 21 preview bytecode "will not run on Java 22 at all, even with preview enabled": the minor-version tag does not mean "this class uses a preview feature", it means "this class uses this specific release's preview feature", and Java 22's --enable-preview unlocks Java 22's preview APIs, not Java 21's already-changed-or-gone ones. The flag is deliberately not a compatibility promise across versions — it is closer to a lock that only the version that cut the key can open.
A JEP's status line is the process this maps onto. A JEP moves Draft → Candidate → Proposed to Target → Integrated, and, for a feature with a preview period, Integrated (as a preview) at least once before Closed / Delivered as GA — sometimes through a second or third preview, each one free to change the API again, which is exactly what happened to StructuredTaskScope between its Java 21 preview and its later ones. A JEP can also close as Withdrawn, which is what "incubator means years, not releases" is a symptom of: an incubating API has not yet earned a JEP number promoting it to preview, and there is no clock running on when, or whether, it will.
Try it yourself
Work out what actually gets checked
A team compiles OrderService.java, which uses a preview feature, with javac --release 21 --enable-preview. They deploy the resulting .class file to a fleet still running plain java -jar app.jar on a Java 21 runtime, no flags. What happens, and why doesn't the missing runtime flag get caught at compile time?
Answer
The class fails to load: java.lang.UnsupportedClassVersionError, because the runtime is not launched with --enable-preview, and the JVM's class-file verifier refuses to load any class whose minor version is 0xFFFF unless that exact flag is present at run time too — matching the JDK major version is necessary but not sufficient. Compile time and run time are two separate, independently-required gates by design: --enable-preview at compile time only controls whether javac accepts preview syntax and stamps the output; it says nothing about how the resulting class file will be loaded later, possibly by a different process, days later, that javac has no way to inspect. That separation is exactly why preview features are hard to ship by accident — a .class file compiled with the flag is a live grenade that only detonates (fails loudly) when finally deployed without it, rather than failing at the build step where it would be caught immediately.
Misconceptions
- "A preview feature compiled once will keep working as long as the major version matches." It has to match the exact feature release, not just "Java 21 or later" — the class-file minor version
0xFFFFis checked against the running JVM's own version, and a Java 21 preview class does not load on Java 22 even though 22 is newer and also supports--enable-preview, because 22's preview APIs are 22's, not 21's. - "Incubator and preview are the same maturity level, just different names." Incubator (a
jdk.incubator.*module, unlocked with--add-modules) is a step before a feature has a JEP proposing it as a language or API preview; there is no class-file-level lock or two-flag ceremony because incubator features are ordinary APIs on a separate module, not a special bytecode dialect — but there is also no committed timeline at all, which is why the vector API has stayed incubating across many releases while most previews resolve within a handful.
Sources
- JEP 12 (Preview Features) — the class-file minor-version marker, the compile-time and run-time
--enable-previewrequirement, and the JEP process states (Candidate, Proposed to Target, Integrated). - JEP 11 (Incubator Modules) — the
jdk.incubator.*module convention and how it differs from a language/API preview. - OpenJDK JEP process documentation (openjdk.org/jeps) — the full status lifecycle, including Withdrawn.
- The structured concurrency JEP series (Java 21's first preview through its later previews on openjdk.org/jeps) — the
StructuredTaskScopeAPI shape change this lesson traces.