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,41 @@
|
||||
# ScopedValue (JEP 506). Preview API in 21, final in 25.
|
||||
|
||||
$ javac ScopedValueDemo.java (JDK 21, no flag)
|
||||
<repo>/lanes/src/ScopedValueDemo.java:9: error: ScopedValue is a preview API and is disabled by default.
|
||||
static final ScopedValue<String> CURRENT_USER = ScopedValue.newInstance();
|
||||
^
|
||||
(use --enable-preview to enable preview APIs)
|
||||
<repo>/lanes/src/ScopedValueDemo.java:9: error: ScopedValue is a preview API and is disabled by default.
|
||||
static final ScopedValue<String> CURRENT_USER = ScopedValue.newInstance();
|
||||
^
|
||||
(use --enable-preview to enable preview APIs)
|
||||
<repo>/lanes/src/ScopedValueDemo.java:13: error: ScopedValue is a preview API and is disabled by default.
|
||||
ScopedValue.where(CURRENT_USER, "ankur").run(() -> {
|
||||
^
|
||||
(use --enable-preview to enable preview APIs)
|
||||
3 errors
|
||||
exit=1
|
||||
|
||||
$ javac ScopedValueDemo.java (JDK 25, no flag)
|
||||
exit=0
|
||||
$ java ScopedValueDemo (JDK 25)
|
||||
java.version = 25.0.4.1
|
||||
CHECK ok : inside the scope: CURRENT_USER.get() == ankur
|
||||
CHECK ok : a method that was never passed the value still sees it
|
||||
CHECK ok : outside the scope: CURRENT_USER.get() throws NoSuchElementException
|
||||
|
||||
$ javac ScopedValueDemo.java (JDK 26, no flag)
|
||||
exit=0
|
||||
$ java ScopedValueDemo (JDK 26)
|
||||
java.version = 26.0.2.1
|
||||
CHECK ok : inside the scope: CURRENT_USER.get() == ankur
|
||||
CHECK ok : a method that was never passed the value still sees it
|
||||
CHECK ok : outside the scope: CURRENT_USER.get() throws NoSuchElementException
|
||||
|
||||
$ javac ScopedValueDemo.java (JDK 27, no flag)
|
||||
exit=0
|
||||
$ java ScopedValueDemo (JDK 27)
|
||||
java.version = 27
|
||||
CHECK ok : inside the scope: CURRENT_USER.get() == ankur
|
||||
CHECK ok : a method that was never passed the value still sees it
|
||||
CHECK ok : outside the scope: CURRENT_USER.get() throws NoSuchElementException
|
||||
Reference in New Issue
Block a user