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:
2026-09-21 15:08:50 +00:00
committed by Claude
co-authored by Claude Sonnet 5
commit f59c1de96d
152 changed files with 5049 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
import java.security.DEREncodable;
import java.security.PEM;
import java.security.PEMDecoder;
import java.security.Provider;
import java.security.Security;
/**
* JDK 26 code for the PEM preview API. It compiles on 26 and fails on 27.
* Three things moved between the second and third preview (JEP 524 -> JEP 538):
* 1. DEREncodable was renamed BinaryEncodable
* 2. PEMDecoder.withFactory(Provider) became withFactoriesOf(Provider)
* 3. PEM was a record whose content() returned a String; it is now a class whose content() returns byte[]
* Driven by scripts/broken-on-27.sh, which commits the compiler's own messages.
*/
public class Pem26Style {
public static void main(String[] args) {
String text = "-----BEGIN ANKURM DEMO-----\naGVsbG8=\n-----END ANKURM DEMO-----\n";
DEREncodable decoded = PEMDecoder.of().decode(text); // 1
Provider provider = Security.getProviders()[0];
PEMDecoder viaProvider = PEMDecoder.of().withFactory(provider); // 2
if (decoded instanceof PEM pem) {
String base64Text = pem.content(); // 3
System.out.println(pem.type() + " / " + base64Text);
}
}
}