Add jdk28-preview module: JDK 28 early-access build, value classes, strict init flag, PEM, JSON incubator

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Gth99spB1CzQmBFofXmU4Z
This commit is contained in:
Claude
2026-09-28 08:48:04 +00:00
parent 57a04dc393
commit c8ff3acf09
15 changed files with 221 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
# 00-environment
--- JDK 28 early-access:
openjdk version "28-ea" 2027-03-23
OpenJDK 64-Bit Server VM (build 28-ea+17-1282, mixed mode, sharing)
--- JDK 25:
openjdk version "25.0.4.1" 2026-08-18 LTS
OpenJDK 64-Bit Server VM Temurin-25.0.4.1+1 (build 25.0.4.1+1-LTS, mixed mode, sharing)
@@ -0,0 +1,8 @@
# 01-value-classes: ValueClasses.java on JDK 28 with --enable-preview
p == q: true, equals: true
isValue: true
synchronized on a value object: java.lang.IdentityException: Cannot synchronize on an instance of value class ValueClasses$Point
--- IntegerIdentity.java: same source, three runs
JDK 25: Integer 1000 == Integer 1000: false
JDK 28, no preview: Integer 1000 == Integer 1000: false
JDK 28, --enable-preview: Integer 1000 == Integer 1000: true
@@ -0,0 +1,9 @@
# 02-forgot-the-preview-flag
--- javac ValueClasses.java (no --enable-preview):
src/ValueClasses.java:3: error: value classes are a preview feature and are disabled by default.
value record Point(int x, int y) {}
^
(use --enable-preview to enable value classes)
--- java ValueClasses (compiled with the flag, run without):
Error: LinkageError occurred while loading main class ValueClasses
java.lang.UnsupportedClassVersionError: Preview features are not enabled for ValueClasses (class file version 72.65535). Try running with '--enable-preview'
@@ -0,0 +1,7 @@
# 03-strict-init-flags (javap -v -p, field flags only)
--- StrictFieldProbe$Money
final long cents;
flags: (0x0810) ACC_FINAL, ACC_STRICT_INIT
--- StrictFieldProbe$Legacy
final long cents;
flags: (0x0010) ACC_FINAL
+11
View File
@@ -0,0 +1,11 @@
# 04-pem-encodings (JEP 542): PemRoundTrip.java
--- JDK 28, no flags:
-----BEGIN PUBLIC KEY-----
round trip equal: true
--- JDK 25, no flags:
src/PemRoundTrip.java:10: error: PEMEncoder is a preview API and is disabled by default.
String pem = PEMEncoder.of().encodeToString(kp.getPublic());
^
--- JDK 25, --enable-preview:
-----BEGIN PUBLIC KEY-----
round trip equal: true
@@ -0,0 +1,24 @@
# 05-json-incubator (JEP 540): JsonDemo.java on JDK 28
--- module and API surface:
jdk.incubator.json@28-ea
exports jdk.incubator.json
requires java.base mandated
public static jdk.incubator.json.JsonValue parse(java.lang.String);
public static jdk.incubator.json.JsonValue parse(char[]);
public static java.lang.String toDisplayString(jdk.incubator.json.JsonValue, java.lang.String);
--- without --add-modules:
src/JsonDemo.java:1: error: package jdk.incubator.json is not visible
import jdk.incubator.json.*;
--- with --add-modules jdk.incubator.json:
name = Ada
second language = fr
age + 1 = 37
missing key -> Optional.empty
{
"name": "Ada",
"langs": [
"en",
"fr"
],
"age": 36
}
+8
View File
@@ -0,0 +1,8 @@
# 06-shenandoah (JEP 535: generational mode by default)
--- JDK 28 EA build, -XX:+UseShenandoahGC:
Error occurred during initialization of VM
Option -XX:+UseShenandoahGC not supported
--- JDK 25 Temurin, -XX:+UseShenandoahGC -Xlog:gc*:
[0.007s][info][gc ] Using Shenandoah
[0.009s][info][gc,init] Mode: Snapshot-At-The-Beginning (SATB)
[0.016s][info][gc,metaspace] CDS archive(s) mapped at: [0x0000000020000000-0x0000000020d96000-0x0000000020d96000), size 14245888, SharedBaseAddress: 0x0000000020000000, ArchiveRelocationMode: 1.
+7
View File
@@ -0,0 +1,7 @@
# 07-jep-status (quoted from published articles on 2026-09-28; NOT produced by running code; status changes weekly)
InfoQ, "JDK 27 and JDK 28: What We Know So Far" (https://www.infoq.com/news/2026/08/java-27-so-far/), August 2026:
Targeted to JDK 28: JEP 541 Deprecate the macOS/x64 Port for Removal; JEP 540 Simple JSON API (Incubator);
JEP 539 Strict Field Initialization in the JVM (Preview); JEP 535 Shenandoah GC: Generational Mode by Default; JEP 401 Value Objects (Preview)
Proposed to target: JEP 542 PEM Encodings of Cryptographic Objects
"Scheduled for a GA release in March 2027"
Inside.java, 2026-09-20 (https://inside.java/2026/09/20/jep401-target-jdk28/): "JEP targeted to JDK 28: 401: Value Objects (Preview)"