Skip to content

Commit 8b78902

Browse files
authored
feat(jdk14): add JEP 363 - Remove the Concurrent Mark Sweep (CMS) Garbage Collector (#348)
* feat(java14): add JEP 363 - Remove the Concurrent Mark Sweep (CMS) Garbage Collector * fix: JSON metadata for JEP 363
1 parent 135d2df commit 8b78902

3 files changed

Lines changed: 69 additions & 0 deletions

File tree

src/main/java/org/javademos/init/Java14DemoLoader.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.javademos.java14.jep359.RecordsPreviewDemo;
1313
import org.javademos.java14.jep361.SwitchExpressionsDemo;
1414
import org.javademos.java14.jep362.SolarisSparcRemovalDemo;
15+
import org.javademos.java14.jep363.RemoveTheCMSGarbageCollectorDemo;
1516
import org.javademos.java14.jep364.ZGarbageCollectorOnMacOS;
1617
import org.javademos.java14.jep365.ZGarbageCollectorOnWindows;
1718
import org.javademos.java14.jep366.ParallelScavengeGCCombinationDemo;
@@ -32,6 +33,7 @@ public void loadDemos(Map<Integer, IDemo> demos) {
3233
demos.put(359, new RecordsPreviewDemo());
3334
demos.put(361, new SwitchExpressionsDemo());
3435
demos.put(362, new SolarisSparcRemovalDemo());
36+
demos.put(363, new RemoveTheCMSGarbageCollectorDemo());
3537
demos.put(364, new ZGarbageCollectorOnMacOS());
3638
demos.put(365, new ZGarbageCollectorOnWindows());
3739
demos.put(366, new ParallelScavengeGCCombinationDemo());
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package org.javademos.java14.jep363;
2+
3+
import org.javademos.commons.IDemo;
4+
5+
/// Demo for JDK 14 feature JEP 363 - Remove the Concurrent Mark Sweep (CMS) Garbage Collector.
6+
///
7+
/// JEP history:
8+
/// - JDK 14: [JEP 363 - Remove the Concurrent Mark Sweep (CMS) Garbage Collector](https://openjdk.org/jeps/363)
9+
/// - JDK 9: [JEP 291 - Deprecate the Concurrent Mark Sweep (CMS) Garbage Collector](https://openjdk.org/jeps/291)
10+
///
11+
/// @author yuuuuuuyu
12+
13+
public class RemoveTheCMSGarbageCollectorDemo implements IDemo {
14+
@Override
15+
public void demo() {
16+
info(363);
17+
18+
// The Concurrent Mark Sweep (CMS) garbage collector was a low-pause GC
19+
// designed for applications requiring shorter stop-the-world times.
20+
// It performed part of its mark-and-sweep phases concurrently with
21+
// running application threads.
22+
//
23+
// However, CMS had several drawbacks:
24+
// - High maintenance cost and complex code base in HotSpot.
25+
// - Fragmentation issues due to the non-compacting nature of CMS.
26+
// - Poor scalability and unpredictable long pauses on large heaps.
27+
//
28+
// Because modern GCs like G1 (JEP 248), ZGC (JEP 333), and Shenandoah
29+
// offer better latency and throughput characteristics,
30+
// CMS was first deprecated in JDK 9 (JEP 291) and completely removed
31+
// in JDK 14 under JEP 363.
32+
//
33+
// As of JDK 14 and later, the JVM ignores the option
34+
// "-XX:+UseConcMarkSweepGC" and prints a warning message instead:
35+
// "Ignoring option UseConcMarkSweepGC; support was removed in 14.0"
36+
//
37+
// e.g. (jdk 11) `java -XX:+UseConcMarkSweepGC -version`
38+
// result:
39+
// OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
40+
// openjdk version "11.0.28" 2025-07-15 LTS
41+
// OpenJDK Runtime Environment Microsoft-11913448 (build 11.0.28+6-LTS)
42+
// OpenJDK 64-Bit Server VM Microsoft-11913448 (build 11.0.28+6-LTS, mixed mode, sharing)
43+
//
44+
// e.g. (jdk 17, 25) `java -XX:+UseConcMarkSweepGC -version`
45+
// result:
46+
// Unrecognized VM option 'UseConcMarkSweepGC'
47+
// Error: Could not create the Java Virtual Machine.
48+
// Error: A fatal exception has occurred. Program will exit
49+
//
50+
// Developers migrating from older Java versions should replace CMS
51+
// with modern collectors such as:
52+
// - G1GC (default since JDK 9)
53+
// - ZGC for ultra-low latency workloads
54+
// - Shenandoah for concurrent compaction
55+
//
56+
// No source-level code changes are required — only JVM options and
57+
// performance tuning scripts need to be updated when upgrading.
58+
}
59+
}

src/main/resources/JDK14Info.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@
5555
"link": true,
5656
"code": false
5757
},
58+
{
59+
"jep": 363,
60+
"jdk": 14,
61+
"name": "JEP 363 - Remove the Concurrent Mark Sweep (CMS) Garbage Collector",
62+
"dscr": "Remove the Concurrent Mark Sweep (CMS) garbage collector.",
63+
"link": false,
64+
"code": false
65+
},
5866
{
5967
"jep": 364,
6068
"jdk": 14,

0 commit comments

Comments
 (0)