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 @@ -12,6 +12,7 @@
import org.javademos.java14.jep359.RecordsPreviewDemo;
import org.javademos.java14.jep361.SwitchExpressionsDemo;
import org.javademos.java14.jep362.SolarisSparcRemovalDemo;
import org.javademos.java14.jep363.RemoveTheCMSGarbageCollectorDemo;
import org.javademos.java14.jep364.ZGarbageCollectorOnMacOS;
import org.javademos.java14.jep365.ZGarbageCollectorOnWindows;
import org.javademos.java14.jep366.ParallelScavengeGCCombinationDemo;
Expand All @@ -32,6 +33,7 @@ public void loadDemos(Map<Integer, IDemo> demos) {
demos.put(359, new RecordsPreviewDemo());
demos.put(361, new SwitchExpressionsDemo());
demos.put(362, new SolarisSparcRemovalDemo());
demos.put(363, new RemoveTheCMSGarbageCollectorDemo());
demos.put(364, new ZGarbageCollectorOnMacOS());
demos.put(365, new ZGarbageCollectorOnWindows());
demos.put(366, new ParallelScavengeGCCombinationDemo());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package org.javademos.java14.jep363;

import org.javademos.commons.IDemo;

/// Demo for JDK 14 feature JEP 363 - Remove the Concurrent Mark Sweep (CMS) Garbage Collector.
///
/// JEP history:
/// - JDK 14: [JEP 363 - Remove the Concurrent Mark Sweep (CMS) Garbage Collector](https://openjdk.org/jeps/363)
/// - JDK 9: [JEP 291 - Deprecate the Concurrent Mark Sweep (CMS) Garbage Collector](https://openjdk.org/jeps/291)
///
/// @author yuuuuuuyu

public class RemoveTheCMSGarbageCollectorDemo implements IDemo {
@Override
public void demo() {
info(363);

// The Concurrent Mark Sweep (CMS) garbage collector was a low-pause GC
// designed for applications requiring shorter stop-the-world times.
// It performed part of its mark-and-sweep phases concurrently with
// running application threads.
//
// However, CMS had several drawbacks:
// - High maintenance cost and complex code base in HotSpot.
// - Fragmentation issues due to the non-compacting nature of CMS.
// - Poor scalability and unpredictable long pauses on large heaps.
//
// Because modern GCs like G1 (JEP 248), ZGC (JEP 333), and Shenandoah
// offer better latency and throughput characteristics,
// CMS was first deprecated in JDK 9 (JEP 291) and completely removed
// in JDK 14 under JEP 363.
//
// As of JDK 14 and later, the JVM ignores the option
// "-XX:+UseConcMarkSweepGC" and prints a warning message instead:
// "Ignoring option UseConcMarkSweepGC; support was removed in 14.0"
//
// e.g. (jdk 11) `java -XX:+UseConcMarkSweepGC -version`
// result:
// OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
// openjdk version "11.0.28" 2025-07-15 LTS
// OpenJDK Runtime Environment Microsoft-11913448 (build 11.0.28+6-LTS)
// OpenJDK 64-Bit Server VM Microsoft-11913448 (build 11.0.28+6-LTS, mixed mode, sharing)
//
// e.g. (jdk 17, 25) `java -XX:+UseConcMarkSweepGC -version`
// result:
// Unrecognized VM option 'UseConcMarkSweepGC'
// Error: Could not create the Java Virtual Machine.
// Error: A fatal exception has occurred. Program will exit
//
// Developers migrating from older Java versions should replace CMS
// with modern collectors such as:
// - G1GC (default since JDK 9)
// - ZGC for ultra-low latency workloads
// - Shenandoah for concurrent compaction
//
// No source-level code changes are required — only JVM options and
// performance tuning scripts need to be updated when upgrading.
}
}
8 changes: 8 additions & 0 deletions src/main/resources/JDK14Info.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@
"link": true,
"code": false
},
{
"jep": 363,
"jdk": 14,
"name": "JEP 363 - Remove the Concurrent Mark Sweep (CMS) Garbage Collector",
"dscr": "Remove the Concurrent Mark Sweep (CMS) garbage collector.",
"link": false,
"code": false
},
{
"jep": 364,
"jdk": 14,
Expand Down