JEP 543 has been integrated into JDK 28, making java.util.concurrent.StructuredTaskScope a permanent API after seven preview rounds. The change removes preview annotations but leaves method signatures intact. Teams using the JDK 27 preview can recompile against a JDK 28 early-access build containing the change without rewriting their structured concurrency code. JDK 28 is scheduled for general availability in March 2027.
What a task scope guarantees
Consider a request handler that needs both a user record and an order. With ExecutorService and separate Future objects, the handler can return while a lookup is still running, and a failure may go unnoticed until the caller invokes Future.get() on that lookup. A StructuredTaskScope ties both lookups to the lifetime of the request: the handler cannot leave the scope until both subtask threads have terminated.
With the default StructuredTaskScope.open() policy, the thread that opens the scope calls fork() for each lookup, starting a virtual thread by default. It then calls join() and, on success, reads both results with Subtask.get(). If either lookup fails, the scope cancels the other and join() throws ExecutionException. Closing the scope at the end of a try-with-resources block cancels unfinished subtasks and waits for their threads to terminate.
If multiple subtasks fail concurrently, callers cannot rely on which failure join() reports. Viktor Klang raised the question during code review, and JEP owner Alan Bateman revised the Javadoc to promise only that the exception comes from one of the failed subtasks.
The completion policy is configurable. For example, Joiner.anySuccessfulOrThrow() returns the first successful result and cancels the remaining work. A custom joiner can instead wait for a quorum of replica reads and declare an application-specific checked exception, such as QuorumException, that join() throws directly. For debugging, subtasks inherit ScopedValue bindings and appear beneath their parent thread in JSON thread dumps.
Migration depends on the preview version
Structured concurrency incubated in JDK 19 and 20 before appearing in preview in every release from JDK 21 through 27. For teams on JDK 27, the move to the final API is a build change: remove --enable-preview from compiler, test-runner and launch settings if no other feature requires it, then recompile on JDK 28. Libraries using the final API will no longer need their users to enable preview features for structured concurrency.
Teams moving from JDK 26 also need to account for changes introduced in JDK 27:
- Built-in throwing joiners use
ExecutionExceptionrather than the preview-onlyFailedException. Custom joiners take a third type parameter,R_X, specifying the exceptionjoin()can throw. StructuredTaskScope.TimeoutExceptionwas removed. With the default policy, callers distinguish a timeout from a subtask failure by checking forCancelledByTimeoutExceptionas the cause ofExecutionException.Joiner.awaitAll()is no longer available, and the abstracttimeout()method replaces theonTimeout()callback.
For projects staying on JDK 25, the velo/structured-concurrency project has backported the JEP 543 API and provides a guide for switching to the native JDK classes after an upgrade.