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
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
$ javac src/VisitorVersion.java && java VisitorVersion (21.0.10+7-Ubuntu-124.04)
|
||||
Card[last4=4242, amount=500] -> fee 10
|
||||
Upi[vpa=ankur@bank, amount=500] -> fee 0
|
||||
NetBanking[bank=HDFC, amount=500] -> fee 15
|
||||
|
||||
$ javac src/VisitorVersion.java && java VisitorVersion (25.0.4.1+1-LTS)
|
||||
Card[last4=4242, amount=500] -> fee 10
|
||||
Upi[vpa=ankur@bank, amount=500] -> fee 0
|
||||
NetBanking[bank=HDFC, amount=500] -> fee 15
|
||||
|
||||
$ javac src/VisitorVersion.java && java VisitorVersion (27+35)
|
||||
Card[last4=4242, amount=500] -> fee 10
|
||||
Upi[vpa=ankur@bank, amount=500] -> fee 0
|
||||
NetBanking[bank=HDFC, amount=500] -> fee 15
|
||||
|
||||
$ javac broken/VisitorAdded.java (21.0.10+7-Ubuntu-124.04)
|
||||
broken/VisitorAdded.java:9: error: Fee is not abstract and does not override abstract method visitWallet(Wallet) in Visitor
|
||||
static class Fee implements Visitor<Long> {
|
||||
^
|
||||
broken/VisitorAdded.java:13: error: Label is not abstract and does not override abstract method visitWallet(Wallet) in Visitor
|
||||
static class Label implements Visitor<String> {
|
||||
^
|
||||
2 errors
|
||||
|
||||
$ javac broken/VisitorAdded.java (25.0.4.1+1-LTS)
|
||||
broken/VisitorAdded.java:9: error: Fee is not abstract and does not override abstract method visitWallet(Wallet) in Visitor
|
||||
static class Fee implements Visitor<Long> {
|
||||
^
|
||||
broken/VisitorAdded.java:13: error: Label is not abstract and does not override abstract method visitWallet(Wallet) in Visitor
|
||||
static class Label implements Visitor<String> {
|
||||
^
|
||||
2 errors
|
||||
|
||||
$ javac broken/VisitorAdded.java (27+35)
|
||||
broken/VisitorAdded.java:9: error: Fee is not abstract and does not override abstract method visitWallet(Wallet) in Visitor
|
||||
static class Fee implements Visitor<Long> {
|
||||
^
|
||||
broken/VisitorAdded.java:13: error: Label is not abstract and does not override abstract method visitWallet(Wallet) in Visitor
|
||||
static class Label implements Visitor<String> {
|
||||
^
|
||||
2 errors
|
||||
Reference in New Issue
Block a user