Files
Claude 2ebea58d39 Add jep513 module: flexible constructor bodies on JDK 25 and 27
Runnable sources, broken examples and captured transcripts for the ankurm.com JEP 513 article, including the JDK 25 vs 27 compiler wording differences.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TF9JWFvJSNm6HVzswzZU5a
2026-09-24 10:42:36 +00:00

15 lines
540 B
Java

// Written with System.out so that JDK 21 can compile it: the ONLY thing wrong with it on 21 is the statement before super(...).
public class OnJdk21 {
static class Person { Person(String n) {} }
static class Employee extends Person {
Employee(String name, int salary) {
if (salary < 0) throw new IllegalArgumentException("negative");
super(name.strip());
}
}
public static void main(String[] args) {
new Employee(" a ", 1);
System.out.println("constructed");
}
}