diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2022-03-24 15:16:29 +0700 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2022-03-24 15:16:29 +0700 |
commit | 50190a1918e66769e0037542054645add1ff8204 (patch) | |
tree | c58ab2b90dc44f8aa90b0ad78eb86de141471bd0 /tests/features199/java18/SwitchPatternPreview2Aspect.aj | |
parent | 6403cc20326190dbc9646b0f9b1819f1bb47fc39 (diff) | |
download | aspectj-50190a1918e66769e0037542054645add1ff8204.tar.gz aspectj-50190a1918e66769e0037542054645add1ff8204.zip |
Upgrade to latest JDT Core Java 18 changes, activate J18 preview tests
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'tests/features199/java18/SwitchPatternPreview2Aspect.aj')
-rw-r--r-- | tests/features199/java18/SwitchPatternPreview2Aspect.aj | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/tests/features199/java18/SwitchPatternPreview2Aspect.aj b/tests/features199/java18/SwitchPatternPreview2Aspect.aj index ee5dbbd68..4170b4d15 100644 --- a/tests/features199/java18/SwitchPatternPreview2Aspect.aj +++ b/tests/features199/java18/SwitchPatternPreview2Aspect.aj @@ -1,28 +1,26 @@ -import java.util.Locale; - aspect SwitchPatternPreview2Aspect { - Object around(Object o): execution(* doSomethingWithObject(*)) && args(o) { + Object around(Integer i): execution(* doSomethingWithInteger(*)) && args(i) { System.out.println( - switch (o) { - case -1, 1 -> "special case:" + o; - case Integer i && i > 0 -> "positive integer: " + o; - case Integer i -> "other integer: " + o; - default -> "non-integer: " + o; + switch (i) { + case null -> "value unavailable: " + i; + case -1, 1 -> "absolute value 1: " + i; + case Integer value && value > 0 -> "positive integer: " + i; + default -> "other integer: " + i; } ); - return proceed(o); + return proceed(i); } } class Application { public static void main(String[] args) { - doSomethingWithObject(-1); - doSomethingWithObject(0); - doSomethingWithObject(42); - doSomethingWithObject(-99); - doSomethingWithObject("test"); - doSomethingWithObject(null); + doSomethingWithInteger(-1); + doSomethingWithInteger(0); + doSomethingWithInteger(42); + doSomethingWithInteger(-99); + doSomethingWithInteger(Integer.valueOf(123)); + doSomethingWithInteger(null); } - public static Object doSomethingWithObject(Object o) { return o; } + public static Object doSomethingWithInteger(Integer o) { return o; } } |