import java.util.List; import java.util.concurrent.StructuredTaskScope; import java.util.concurrent.StructuredTaskScope.Joiner; /** * JDK 26 code for the structured concurrency preview. It compiles on 26 and fails on 27: * StructuredTaskScope gained a third type parameter (the exception join() throws), and * FailedException / TimeoutException no longer exist. Driven by scripts/broken-on-27.sh. */ public class StructuredScope26 { public static void main(String[] args) throws Exception { try (StructuredTaskScope> scope = StructuredTaskScope.open(Joiner.allSuccessfulOrThrow())) { scope.fork(() -> "price=42"); List results = scope.join(); System.out.println(results); } catch (StructuredTaskScope.FailedException e) { System.out.println("a subtask failed: " + e.getCause()); } catch (StructuredTaskScope.TimeoutException e) { System.out.println("timed out"); } } }