Class ZgcGenerationalModeExamples
java.lang.Object
net.jrodolfo.java_evolution.java23.zgc_generational_mode.ZgcGenerationalModeExamples
Demonstrates the Java 23 ZGC generational-mode runtime boundary.
Java 23 made generational mode the default for ZGC. This example launches
child JVMs to verify the executable part that is portable on ZGC-capable
builds: ZGC can be selected, -XX:+PrintFlagsFinal reports
UseZGC = true, and GC initialization logs mention young and old
generation workers.
The example does not benchmark garbage collection. Throughput, pause time, heap footprint, and CPU behavior require real workloads and measurement.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordCaptures a child process result.static final recordA JVM flag state reported by-XX:+PrintFlagsFinal. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionExplains the boundary of the executable example.Explains the generational observation behind the Java 23 default change.Captures the status of the oldZGenerationalswitch in Java 24+.booleanChecks whether the current JVM build supports ZGC.Reads the child JVM flag state after selecting ZGC.Captures ZGC initialization logs.
-
Constructor Details
-
ZgcGenerationalModeExamples
public ZgcGenerationalModeExamples()
-
-
Method Details
-
zgcAvailable
Checks whether the current JVM build supports ZGC.- Returns:
truewhen a child JVM starts with-XX:+UseZGC- Throws:
IOException- if the child JVM cannot be startedInterruptedException- if interrupted while waiting for the child JVM
-
zgcFlagState
public ZgcGenerationalModeExamples.VmFlagState zgcFlagState() throws IOException, InterruptedExceptionReads the child JVM flag state after selecting ZGC.- Returns:
- the reported
UseZGCflag state - Throws:
IOException- if the child JVM cannot be startedInterruptedException- if interrupted while waiting for the child JVM
-
zgcInitializationLog
public ZgcGenerationalModeExamples.ProcessResult zgcInitializationLog() throws IOException, InterruptedExceptionCaptures ZGC initialization logs.- Returns:
- child JVM result containing
gc+initoutput - Throws:
IOException- if the child JVM cannot be startedInterruptedException- if interrupted while waiting for the child JVM
-
oldGenerationalSwitchStatus
public ZgcGenerationalModeExamples.ProcessResult oldGenerationalSwitchStatus() throws IOException, InterruptedExceptionCaptures the status of the oldZGenerationalswitch in Java 24+.- Returns:
- child JVM result showing whether the old switch is still meaningful
- Throws:
IOException- if the child JVM cannot be startedInterruptedException- if interrupted while waiting for the child JVM
-
generationalObservation
Explains the generational observation behind the Java 23 default change.- Returns:
- a short explanation
-
benchmarkBoundary
Explains the boundary of the executable example.- Returns:
- a short boundary explanation
-