Files
javademos/sealed/broken/AnonymousSealed.java
Claude ff6130bede Add sealed module: modelling domains with sealed types and exhaustive switch
Payment model, permits and the three modifiers, default-branch trap, generic and recursive hierarchies, visitor comparison, run-time enforcement, modules. Transcripts from JDK 21, 25 and 27.

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

8 lines
272 B
Java

public class AnonymousSealed {
sealed interface Payment permits Card {}
record Card(long amount) implements Payment {}
static Payment sneaky() {
return new Payment() {}; // an anonymous class is a subtype nobody listed
}
}