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,17 @@
|
||||
import java.lang.LazyConstant;
|
||||
|
||||
/**
|
||||
* JDK 26 code for the lazy constants preview. It compiles on 26 and fails on 27:
|
||||
* LazyConstant.orElse(...) and LazyConstant.isInitialized() were removed in the third preview.
|
||||
* Driven by scripts/broken-on-27.sh.
|
||||
*/
|
||||
public class Lazy26 {
|
||||
static final LazyConstant<String> GREETING = LazyConstant.of(() -> "hello");
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (!GREETING.isInitialized()) {
|
||||
System.out.println("not yet: " + GREETING.orElse("<unset>"));
|
||||
}
|
||||
System.out.println(GREETING.get());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user