Java 27 and 26: runnable demos and captured output for every JEP, plus version lanes
Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01B38FGKKam5SCGgwgduVAh3
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Thread.stop() on 25: still compiles (with a deprecation-for-removal warning) but has thrown
|
||||
* UnsupportedOperationException since Java 20. It is REMOVED from the API in Java 26 (see recap26/src/broken/ThreadStopGone.java,
|
||||
* docs/output/73-removed-in-26.txt). Thread.suspend() and resume() are checked the same way.
|
||||
* Chapter: docs/14-lanes-21-to-25.md
|
||||
*/
|
||||
public class ThreadStopRuntime {
|
||||
@SuppressWarnings({"removal", "deprecation"})
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println("java.version = " + System.getProperty("java.version"));
|
||||
Thread t = new Thread(() -> {
|
||||
try { Thread.sleep(1000); } catch (InterruptedException ignored) { }
|
||||
});
|
||||
t.start();
|
||||
try {
|
||||
t.stop();
|
||||
System.out.println("Thread.stop(): accepted");
|
||||
} catch (UnsupportedOperationException e) {
|
||||
System.out.println("Thread.stop(): UnsupportedOperationException");
|
||||
}
|
||||
t.interrupt();
|
||||
t.join();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user