Files
javademos/structured-concurrency-final/output/01-server.txt
T
Claude c93a1fffbb Add structured-concurrency-final module: StructuredTaskScope final in JDK 28 (JEP 543), run on 28-ea, 27, 26 and 25
Runnable demos for the ankurm.com structured-concurrency-java article: the ExecutorService thread leak and its fix, every built-in Joiner,
structure violations, timeouts, a custom Joiner, JSON thread dumps (in-process and jcmd), scoped values, javap diffs of the API on 25, 26, 27 and 28-ea,
compiler output for six pieces of 25/26-era code, and the preview class-file trap between 27 and 28. Transcripts in output/.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CifR2BE7PBvRy5hT8TS9oz
2026-10-26 02:01:31 +00:00

36 lines
1.6 KiB
Plaintext

$ javac src/Server.java && java Server (28-beta+21-ea)
Response[user=Alice, order=42]
Runtime: 28-beta+21-ea
$ javac --enable-preview --release 27 src/Server.java && java --enable-preview Server (27.0.1.0.2+1)
Response[user=Alice, order=42]
Runtime: 27.0.1.0.2+1
$ javac src/Server.java (27.0.1.0.2+1)
src/Server.java:2: error: StructuredTaskScope is a preview API and is disabled by default.
import java.util.concurrent.StructuredTaskScope;
^
(use --enable-preview to enable preview APIs)
src/Server.java:3: error: StructuredTaskScope is a preview API and is disabled by default.
import java.util.concurrent.StructuredTaskScope.Subtask;
^
(use --enable-preview to enable preview APIs)
src/Server.java:3: error: Subtask is a preview API and is disabled by default.
import java.util.concurrent.StructuredTaskScope.Subtask;
^
(use --enable-preview to enable preview APIs)
src/Server.java:22: error: StructuredTaskScope is a preview API and is disabled by default.
try (var scope = StructuredTaskScope.open()) { // 1. open
^
(use --enable-preview to enable preview APIs)
src/Server.java:23: error: Subtask is a preview API and is disabled by default.
Subtask<String> user = scope.fork(this::findUser); // 2. fork
^
(use --enable-preview to enable preview APIs)
src/Server.java:24: error: Subtask is a preview API and is disabled by default.
Subtask<Integer> order = scope.fork(this::fetchOrder); // fork
^
(use --enable-preview to enable preview APIs)
6 errors
exit=1