diff --git a/src/main/java/org/javademos/init/Java14DemoLoader.java b/src/main/java/org/javademos/init/Java14DemoLoader.java index 47605d3..4eb36df 100644 --- a/src/main/java/org/javademos/init/Java14DemoLoader.java +++ b/src/main/java/org/javademos/init/Java14DemoLoader.java @@ -16,6 +16,7 @@ import org.javademos.java14.jep364.ZGarbageCollectorOnMacOS; import org.javademos.java14.jep365.ZGarbageCollectorOnWindows; import org.javademos.java14.jep366.ParallelScavengeGCCombinationDemo; +import org.javademos.java14.jep367.Pack200Demo; import org.javademos.java14.jep368.TextBlockSecondPreviewDemo; import org.javademos.java14.jep370.ForeignMemoryAccessDemo; @@ -37,6 +38,7 @@ public void loadDemos(Map demos) { demos.put(364, new ZGarbageCollectorOnMacOS()); demos.put(365, new ZGarbageCollectorOnWindows()); demos.put(366, new ParallelScavengeGCCombinationDemo()); + demos.put(367, new Pack200Demo()); demos.put(368, new TextBlockSecondPreviewDemo()); demos.put(370, new ForeignMemoryAccessDemo()); } diff --git a/src/main/java/org/javademos/java14/jep367/Pack200Demo.java b/src/main/java/org/javademos/java14/jep367/Pack200Demo.java new file mode 100644 index 0000000..363dae5 --- /dev/null +++ b/src/main/java/org/javademos/java14/jep367/Pack200Demo.java @@ -0,0 +1,40 @@ +package org.javademos.java14.jep367; + +import org.javademos.commons.IDemo; + +/// Demo for JDK 14 feature JEP 367 - Remove the Pack200 Tools and API. +/// +/// JEP 367 removed the Pack200 API and tools from the JDK. This demo documents the +/// removal and shows a small runtime check that the `java.util.jar.Pack200` class is +/// no longer available on the classpath of modern JDKs. Since Pack200 was removed, +/// attempting to reference the API may fail at runtime (NoClassDefFoundError) when +/// running on a JDK that no longer contains it. +/// +/// JEP link: https://openjdk.org/jeps/367 +/// +/// @author adripo +public class Pack200Demo implements IDemo { + + @Override + public void demo() { + info(367); + + System.out.println("Checking availability of Pack200 classes at runtime..."); + + try { + // Try to load the Pack200 class reflectively. On JDKs where Pack200 + // has been removed this will throw ClassNotFoundException. + Class.forName("java.util.jar.Pack200"); + // If the class is present, show a short note: + System.out.println("java.util.jar.Pack200 is present on this JVM. Pack200 APIs are available."); + } catch (ClassNotFoundException | NoClassDefFoundError ex) { + // Expected on JDKs that removed Pack200 (JDK 14 removal) + System.out.println("Pack200 classes are NOT available on this JVM (removed by JEP 367)."); + System.out.println("If you still need Pack200 functionality consider using an external library or alternate packaging/compression."); + System.out.println("Pack200 was deprecated for removal earlier and removed by JEP 367 in JDK 14."); + } + + System.out.println(); + } + +} diff --git a/src/main/resources/JDK14Info.json b/src/main/resources/JDK14Info.json index e05c551..15060e7 100644 --- a/src/main/resources/JDK14Info.json +++ b/src/main/resources/JDK14Info.json @@ -87,6 +87,14 @@ "link": false, "code": true }, + { + "jep": 367, + "jdk": 14, + "name": "JEP 367 - Remove the Pack200 Tools and API", + "dscr": "Removes the Pack200 tools and API from the JDK. This entry documents the removal and points users to alternatives.", + "link": false, + "code": true + }, { "jep": 368, "jdk": 14,