Java 27 and 26: runnable demos and captured output for every JEP, plus version lanes

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B38FGKKam5SCGgwgduVAh3
This commit is contained in:
2026-09-21 15:08:50 +00:00
committed by Claude
co-authored by Claude Sonnet 5
commit f59c1de96d
152 changed files with 5049 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
import com.sun.management.HotSpotDiagnosticMXBean;
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
import java.util.stream.Collectors;
/**
* Prints which garbage collector the JVM picked when nobody asked for one, and why.
*
* <p>The "why" is the interesting part: HotSpot records the ORIGIN of every flag value.
* {@code ERGONOMIC} means the JVM chose it by looking at the machine; {@code DEFAULT} means
* it is simply the built-in value; {@code COMMAND_LINE} means somebody typed it.
*
* <p>Explained in docs/02-g1-default.md. Run by scripts/g1-default.sh.
*/
public class GcReport {
public static void main(String[] args) {
Runtime rt = Runtime.getRuntime();
System.out.println("java.version = " + System.getProperty("java.version"));
System.out.println("availableCpus = " + rt.availableProcessors());
System.out.println("maxHeapMB = " + rt.maxMemory() / (1024 * 1024));
System.out.println("collector beans = " + ManagementFactory.getGarbageCollectorMXBeans().stream()
.map(GarbageCollectorMXBean::getName).collect(Collectors.joining(", ")));
HotSpotDiagnosticMXBean hs = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
for (String flag : new String[] {"UseG1GC", "UseSerialGC", "UseParallelGC"}) {
var opt = hs.getVMOption(flag);
System.out.printf("%-17s = %-5s (origin %s)%n", flag, opt.getValue(), opt.getOrigin());
}
}
}