Add java28-features module: the JDK 28 JEP list so far, one example per JEP on 28-ea+26, behaviour changes against JDK 27

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b7N4ZDbUtA3ofqAqRV
This commit is contained in:
asmhatre
2026-12-03 09:10:29 +05:30
co-authored by Claude Sonnet 5.5
parent c0062ea398
commit d4b8552957
37 changed files with 767 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
$ java -version
openjdk version "28-ea" 2027-03-23
OpenJDK Runtime Environment (build 28-ea+26-2195)
OpenJDK 64-Bit Server VM (build 28-ea+26-2195, mixed mode, sharing)
$ JDK 27 comparison build
openjdk version "27.0.1.1" 2026-11-17
OpenJDK Runtime Environment (build 27.0.1.1+4-22)
OpenJDK 64-Bit Server VM (build 27.0.1.1+4-22, mixed mode, sharing)
$ nproc
2
$ uname -sm
Linux x86_64
@@ -0,0 +1,14 @@
$ java --enable-preview src/ValueClassDemo.java
value record a == b : true
ordinary record a == b: false
Money has identity : false
Integer 1996 == 1996 : true
IdentityException: Cannot synchronize on an instance of value class java.lang.Integer
$ java src/IntegerEquality.java
x == y : false
x.equals(y) : true
$ java --enable-preview src/IntegerEquality.java
x == y : true
x.equals(y) : true
@@ -0,0 +1,12 @@
$ javac broken/RecordThis.java
exit 0
$ javac --enable-preview --release 28 broken/RecordThis.java
broken/RecordThis.java:10: error: reference to this may only appear after an explicit constructor invocation
nullCheck(label, this);
^
broken/RecordThis.java:11: error: reference to this may only appear after an explicit constructor invocation
nullCheck(edges, this);
^
2 errors
exit 1
@@ -0,0 +1,17 @@
$ javac --enable-preview --release 28 src/StrictFields.java
Note: src/StrictFields.java uses preview features of Java SE 28.
Note: Recompile with -Xlint:preview for details.
$ java --enable-preview -cp classes StrictFields classes
StrictFields$Point x flags=0x0812 strictly-initialized=true
StrictFields$Point y flags=0x0812 strictly-initialized=true
StrictFields$Plain x flags=0x0812 strictly-initialized=true
StrictFields$Plain y flags=0x0812 strictly-initialized=true
$ javac --enable-preview --release 28 broken/EarlyConstruction.java
broken/EarlyConstruction.java:6: error: strict field id is not initialized before the supertype constructor has been called
super();
^
Note: broken/EarlyConstruction.java uses preview features of Java SE 28.
Note: Recompile with -Xlint:preview for details.
1 error
exit 1
+10
View File
@@ -0,0 +1,10 @@
$ java --add-modules jdk.incubator.json src/JsonDemo.java
WARNING: Using incubator modules: jdk.incubator.json
service : orders
replicas : 3
tags : [java, jdk28]
owner : (none)
missing : (absent)
JsonValueException: JsonNumber is not a JsonString. Path: "{replicas". Location: line 0, position 31.
JsonParseException: Duplicate member name: "a" was already parsed. Path: "{". Location: line 0, position 7.
{"ok":true}
@@ -0,0 +1,9 @@
$ java src/StructuredDemo.java
both succeed:
user ok, order ok
one fails:
user was cancelled
join() threw ExecutionException: order service is down
first success wins:
mirror-A was cancelled
winner: mirror-B ok
+7
View File
@@ -0,0 +1,7 @@
$ java src/PemDemo.java
-----BEGIN PUBLIC KEY-----
MCowBQYDK2VwAyEA2nyOc4Zr8uZvwioD42icFwInLORdN4/VF2xQIrgpUM8=
-----END PUBLIC KEY-----
public key round trip : true
-----BEGIN ENCRYPTED PRIVATE KEY-----
private key round trip: true
@@ -0,0 +1,7 @@
$ java --enable-preview src/LazyDemo.java
before first get(), computations = 0
loaded after 1000 concurrent get() calls, computations = 1
size without computing anything: 5
computing element 3
sq9
sq9
+19
View File
@@ -0,0 +1,19 @@
$ java --add-modules jdk.incubator.vector src/VectorDemo.java
WARNING: Using incubator modules: jdk.incubator.vector
lanes per vector : 16
sum 1..1003 : 503506
$ JDK 28: java --add-modules jdk.incubator.vector src/Float16Demo.java
WARNING: Using incubator modules: jdk.incubator.vector
Species[Float16, 8, S_128_BIT]
$ JDK 27: java --add-modules jdk.incubator.vector src/Float16Demo.java
WARNING: Using incubator modules: jdk.incubator.vector
src/Float16Demo.java:5: error: cannot find symbol
var species = Float16Vector.SPECIES_128;
^
symbol: variable Float16Vector
location: class Float16Demo
1 error
error: compilation failed
exit 1
+37
View File
@@ -0,0 +1,37 @@
$ JDK 27: java -XX:+UseZGC -Xlog:gc+init HeapProbe
Large Page Support: Disabled
Min Capacity: 8M
Initial Capacity: 8M
Max Capacity: 1536M
Soft Max Capacity: 1382M
init=8M max=1536M
collector bean: ZGC Minor Cycles
collector bean: ZGC Minor Pauses
collector bean: ZGC Major Cycles
collector bean: ZGC Major Pauses
$ JDK 28: java -XX:+UseZGC -Xlog:gc+init HeapProbe
Large Page Support: Enabled (Transparent, JVM enforced)
Min Capacity: 8M
Initial Capacity: 8M
Max Capacity: 1536M
Soft Max Capacity: 1382M
Heap Sizing: Fixed
init=8M max=1536M
collector bean: ZGC Minor Cycles
collector bean: ZGC Minor Pauses
collector bean: ZGC Major Cycles
collector bean: ZGC Major Pauses
$ JDK 28: java -XX:+UseZGC -XX:+ZAdaptiveHeapSizing -Xlog:gc+init HeapProbe
Large Page Support: Enabled (Transparent, JVM enforced)
Min Capacity: 2M
Initial Capacity: 2M
Max Capacity: 8022M
Heap Sizing: Adaptive (Implicit Boundaries)
init=2M max=6144M
collector bean: ZGC Minor Cycles
collector bean: ZGC Minor Pauses
collector bean: ZGC Major Cycles
collector bean: ZGC Major Pauses
+4
View File
@@ -0,0 +1,4 @@
$ java -XX:+UseShenandoahGC -version
Error occurred during initialization of VM
Option -XX:+UseShenandoahGC not supported
exit 1
+21
View File
@@ -0,0 +1,21 @@
$ java -XX:AOTCacheOutput=app.aot -cp app.jar AotApp
checksum 183000
Temporary AOTConfiguration recorded: app.aot.config
Reading AOTConfiguration app.aot.config and writing AOTCache app.aot
AOTCache creation is complete: app.aot 12713984 bytes
Removed temporary AOT configuration file app.aot.config
$ java -XX:AOTMode=required -XX:AOTCache=app.aot -XX:+PrintCompilation -cp app.jar AotApp
lines with the A (AOT code) flag: 173
22 168 A 2 java.lang.Byte::toUnsignedInt (6 bytes)
22 170 A 2 java.lang.Math::floorMod (20 bytes)
22 171 A 2 java.util.ImmutableCollections$SetN::probe (56 bytes)
22 172 A 2 jdk.internal.util.ArraysSupport::vectorizedHashCode (158 bytes)
22 173 A 2 jdk.internal.util.ArraysSupport::hashCodeOfUnsigned (55 bytes)
$ same run with -XX:+UnlockDiagnosticVMOptions -XX:-AOTCodeCaching
lines with the A (AOT code) flag: 0
wall-clock milliseconds for the whole process, 15 interleaved runs each, median [min-max]
no AOT cache 447 [322-634]
AOT cache, AOT code disabled 343 [245-1049]
AOT cache with AOT code 186 [142-417]
@@ -0,0 +1,27 @@
$ JDK 27: keytool -genkeypair -storetype PKCS12 ... ; openssl pkcs12 -info -noout
OpenSSL 3.0.13 30 Jan 2024 (Library: OpenSSL 3.0.13 30 Jan 2024)
MAC: sha256, Iteration 10000
MAC length: 32, salt length: 20
$ JDK 28: keytool -genkeypair -storetype PKCS12 ... ; openssl pkcs12 -info -noout
OpenSSL 3.0.13 30 Jan 2024 (Library: OpenSSL 3.0.13 30 Jan 2024)
MAC: PBMAC1, Iteration 1
MAC length: 32, salt length: 8
Mac verify error: invalid password?
error:0308010C:digital envelope routines:inner_evp_generic_fetch:unsupported:../crypto/evp/evp_fetch.c:386:Global default library context, Algorithm (PBMAC1 : 0), Properties (<null>)
error:0308010C:digital envelope routines:inner_evp_generic_fetch:unsupported:../crypto/evp/evp_fetch.c:386:Global default library context, Algorithm (PBMAC1 : 0), Properties (<null>)
$ JDK 27 keytool reading the JDK 28 keystore
Keystore type: PKCS12
demo, Dec 3, 2026, PrivateKeyEntry,
$ older keytool reading the JDK 28 keystore: openjdk version "25.0.5.1" 2026-11-17 LTS
Keystore type: PKCS12
demo, Dec 3, 2026, PrivateKeyEntry,
$ older keytool reading the JDK 28 keystore: openjdk version "21.0.13.1" 2026-11-17
keytool error: java.io.IOException: Integrity check failed: java.security.NoSuchAlgorithmException: Algorithm HmacPBE1.2.840.113549.1.5.14 not available
$ JDK 28: keytool -J-Dkeystore.pkcs12.macAlgorithm=HmacPBESHA256 -genkeypair ... ; openssl pkcs12 -info -noout
MAC: sha256, Iteration 10000
MAC length: 32, salt length: 20
@@ -0,0 +1,24 @@
$ JDK 27: java behaviour/Behaviour.java
-- ListFormat with single quotes in a custom pattern
[ {0}, foo ]
-- RSA/ECB/PKCS1Padding
cipher initialised
-- canonical size_t layout
j8 equals JAVA_LONG: true
-- ReflectionFactory on a non-serializable class
one-arg : Behaviour$NotSerializable()
two-arg : returned a constructor
$ JDK 28: java behaviour/Behaviour.java
-- ListFormat with single quotes in a custom pattern
[ 'bar', foo ]
-- RSA/ECB/PKCS1Padding
WARNING: An outdated Cipher algorithm has been called by Behaviour (file:behaviour/Behaviour.java)
WARNING: RSA/ECB/PKCS1Padding will be disabled by default in a future release
cipher initialised
-- canonical size_t layout
uj8 equals JAVA_LONG: false
-- ReflectionFactory on a non-serializable class
one-arg : null
two-arg : UnsupportedOperationException: Run with -Djdk.reflect.allowNonSerializableConstruction=true to temporarily re-enable this method
@@ -0,0 +1,20 @@
$ JDK 27: javac behaviour/RawConditional.java
exit 0
$ JDK 28: javac behaviour/RawConditional.java
behaviour/RawConditional.java:5: error: incompatible types: Object cannot be converted to Integer
return (b ? parameterized : raw).get(0);
^
1 error
exit 1
$ JDK 27: javac behaviour/SwitchGuard.java
exit 0
$ JDK 28: javac behaviour/SwitchGuard.java
behaviour/SwitchGuard.java:6: error: unreported exception Exception; must be caught or declared to be thrown
case String s when check(s) -> "empty";
^
1 error
exit 1
@@ -0,0 +1,16 @@
$ JDK 27: java src/StructuredDemo.java (no flags)
src/StructuredDemo.java:2: error: StructuredTaskScope is a preview API and is disabled by default.
import java.util.concurrent.StructuredTaskScope.Joiner;
^
(use --enable-preview to enable preview APIs)
src/StructuredDemo.java:2: error: Joiner is a preview API and is disabled by default.
import java.util.concurrent.StructuredTaskScope.Joiner;
$ JDK 27: java src/PemDemo.java (no flags)
src/PemDemo.java:4: error: PEMDecoder is a preview API and is disabled by default.
import java.security.PEMDecoder;
^
(use --enable-preview to enable preview APIs)
src/PemDemo.java:5: error: PEMEncoder is a preview API and is disabled by default.
import java.security.PEMEncoder;
+2
View File
@@ -0,0 +1,2 @@
$ java src/PlatformCheck.java
Linux / amd64 -> not affected by JEP 541