Add jep512 module: compact source files and instance main methods on JDK 25 and 27

Runnable sources, broken examples and captured transcripts for the ankurm.com JEP 512 article,
including the measured launch order and a private-constructor difference between 25 and 27.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TF9JWFvJSNm6HVzswzZU5a
This commit is contained in:
Claude
2026-09-24 10:32:47 +00:00
parent 6b5a918278
commit e0cb6e83e2
34 changed files with 490 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
// A compact source file is a whole class body: fields, methods, and nested types all sit at the top level.
// Nothing here is imported. List, Map, TreeMap, Collectors and BigDecimal all live in java.base.
String greeting = "hello";
int calls = 0;
record Point(int x, int y) {
double distance() { return Math.sqrt(x * x + y * y); }
}
String shout(String s) {
calls++;
return s.toUpperCase() + "!";
}
void main() {
List<String> words = List.of("banana", "apple", "cherry");
Map<String, Integer> lengths = new TreeMap<>();
for (String w : words) lengths.put(w, w.length());
IO.println(shout(greeting));
IO.println(words.stream().sorted().collect(Collectors.joining(", ")));
IO.println(lengths);
IO.println(new BigDecimal("1.10").add(BigDecimal.ONE));
IO.println(new Point(3, 4) + " is " + new Point(3, 4).distance() + " from the origin");
IO.println("calls so far: " + calls);
}