Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/org/javademos/init/Java14DemoLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -37,6 +38,7 @@ public void loadDemos(Map<Integer, IDemo> 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());
}
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/org/javademos/java14/jep367/Pack200Demo.java
Original file line number Diff line number Diff line change
@@ -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();
}

}
8 changes: 8 additions & 0 deletions src/main/resources/JDK14Info.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down