diff options
author | Andrew Clement <aclement@vmware.com> | 2025-03-07 10:43:16 -0800 |
---|---|---|
committer | Andrew Clement <aclement@vmware.com> | 2025-03-07 10:43:16 -0800 |
commit | eb56b6e84e24e58f318fb92479f9d9e6fa4c866f (patch) | |
tree | fb1958413e34ed551c7b93e5281aa9ca1fe787de /tests/design | |
parent | 8044fa120adc1f7370b09c1dbf906eff62e1da62 (diff) | |
download | aspectj-master.tar.gz aspectj-master.zip |
The huge change with adopting Java23 is that 1.1 > 1.7 Java are now considered unsupported
by Eclipse JDT, so the many thousands of tests we have that were specifying java versions
lower than 1.8 were all failing with an unsupported version error. All those tests have
had their versions bumped to 1.8.
That is why this commit includes so many changes. For
example where we were specifying 1.5 - which was the case for many many generics/annotations
tests, that is now 1.8. Also, some tests have been deleted because they make no sense now
(verifying expected errors on Java 1.4 for example, errors that just can’t happen with
minimum Java level 1.8).
The biggest impact to tests was when bumping above 1.4 compliance suddenly
there were 100s of adviceDidNotMatch messages. Some of these messages were actual indications
of bad expectations in the test but many of them were just to-be-expected and were fixed
either via an -Xlint:ignore option in the test spec or a SuppressAjWarnings in the test
source.
One or two tests actually revealed real bugs that just didn’t surface with lower
level java versions specified.
A bare minimum of real Java 23 tests have been added just
to get this sanity tested and committed. More would ideally be added.
Other notable changes due to Eclipse JDT changes:
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/*.java
Changes in here because there are now more validations on the code generator methods we were
calling. Now you can’t start manipulating variables without having declared them as proper
local variables, so those extra calls to define them have been added.
org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom
With needing to bump up the java versions, these classes had to be brought up to date with
AST.JLS20 rather than only supporting versions 2/3. This was mostly copying patterns for
the Eclipse classes.
Diffstat (limited to 'tests/design')
-rw-r--r-- | tests/design/eachobject/Tricky3.java | 15 | ||||
-rw-r--r-- | tests/design/intro/Interfaces.java | 70 | ||||
-rw-r--r-- | tests/design/intro/Within.java | 44 | ||||
-rw-r--r-- | tests/design/reflect/Coverage.java | 4 |
4 files changed, 65 insertions, 68 deletions
diff --git a/tests/design/eachobject/Tricky3.java b/tests/design/eachobject/Tricky3.java index 9f03a0369..d38358e1b 100644 --- a/tests/design/eachobject/Tricky3.java +++ b/tests/design/eachobject/Tricky3.java @@ -2,7 +2,8 @@ import org.aspectj.testing.Tester; public class Tricky3 { public static void main(String[] args) { - C c = new SubC(); + C c = new SubC(); + ((SubC)c).m(); } } @@ -14,19 +15,19 @@ class SubC extends C { } aspect A1 pertarget(target(SubC)) { - after() returning (SubC sub): call(new(..)) { - System.out.println("new " + sub); + after(SubC sub) returning: call(* m(..)) && target(sub) { + System.out.println("Called m() on " + sub.getClass().getName()); } } aspect A2 pertarget(call(void SubC.*())) { - after() returning (SubC sub): call(new(..)) { - System.out.println("new " + sub); + after(SubC sub) returning: call(* m(..)) && target(sub) { + System.out.println("Called m() on " + sub.getClass().getName()); } } aspect A3 pertarget(call(void m())) { - after() returning (SubC sub): call(new(..)) { - System.out.println("new " + sub); + after(SubC sub) returning: call(* m(..)) && target(sub) { + System.out.println("Called m() on " + sub.getClass().getName()); } } diff --git a/tests/design/intro/Interfaces.java b/tests/design/intro/Interfaces.java index 67ca0f684..c774b8919 100644 --- a/tests/design/intro/Interfaces.java +++ b/tests/design/intro/Interfaces.java @@ -6,29 +6,29 @@ import org.aspectj.lang.reflect.*; public class Interfaces { public static void main(String[] args) { - String v = I.staticField; - Tester.checkEqual(notes, "I.staticField", "static init of I"); - Tester.checkEqual(v, "I.staticField"); - clearNotes(); - - I i = (I)new C(); - Tester.checkEqual(notes, - "initialize-I instanceField-A* I.instanceField privateField-A* I.privateField-from-A privateField-A* I.privateField-from-B", - "inst init of I"); - Tester.checkEqual(i.instanceField, "I.instanceField"); - clearNotes(); - - v = SubI.staticField; - Tester.checkEqual(notes, "SubI.staticField", "static init of SubI"); - Tester.checkEqual(v, "SubI.staticField"); - clearNotes(); - - SubI si = (SubI)new SubC(); - Tester.checkEqual(notes, - "initialize-I instanceField-A* I.instanceField privateField-A* I.privateField-from-A privateField-A* I.privateField-from-B SubI.instanceField", - "inst init of SubI"); - Tester.checkEqual(si.instanceField, "SubI.instanceField"); - clearNotes(); + String v = I.staticField; + Tester.checkEqual(notes, "I.staticField", "static init of I"); + Tester.checkEqual(v, "I.staticField"); + clearNotes(); + + I i = (I)new C(); + Tester.checkEqual(notes, + "initialize-I instanceField-A* I.instanceField privateField-A* I.privateField-from-A privateField-A* I.privateField-from-B", + "inst init of I"); + Tester.checkEqual(i.instanceField, "I.instanceField"); + clearNotes(); + + v = SubI.staticField; + Tester.checkEqual(notes, "SubI.staticField", "static init of SubI"); + Tester.checkEqual(v, "SubI.staticField"); + clearNotes(); + + SubI si = (SubI)new SubC(); + Tester.checkEqual(notes, + "initialize-I instanceField-A* I.instanceField privateField-A* I.privateField-from-A privateField-A* I.privateField-from-B SubI.instanceField", + "inst init of SubI"); + Tester.checkEqual(si.instanceField, "SubI.instanceField"); + clearNotes(); i.instanceField += "-XXX"; @@ -39,14 +39,12 @@ public class Interfaces { private static List notes = new LinkedList(); public static void clearNotes() { - notes = new LinkedList(); - //System.out.println("***********************************************"); + notes = new LinkedList(); } public static String note(String note) { - notes.add(note); - //System.out.println(note); - return note; + notes.add(note); + return note; } } @@ -59,7 +57,6 @@ class SubC extends C implements SubI { } interface I { - // must follow standard Java rules String staticField = Interfaces.note("I.staticField"); } @@ -70,10 +67,9 @@ interface SubI extends I { aspect A1 { - public String SubI.instanceField = Interfaces.note("SubI.instanceField"); - - public String I.instanceField = Interfaces.note("I.instanceField"); - private String I.privateField = Interfaces.note("I.privateField-from-A"); + public String SubI.instanceField = Interfaces.note("SubI.instanceField"); + public String I.instanceField = Interfaces.note("I.instanceField"); + private String I.privateField = Interfaces.note("I.privateField-from-A"); } aspect A2 { @@ -82,14 +78,14 @@ aspect A2 { aspect A3 { before(I i): !within(I||A*) && set(String I.*) && target(i) { - Interfaces.note(thisJoinPoint.getSignature().toShortString()+"-!I||A*"); // +"::" + thisJoinPoint.getSourceLocation().getWithinType()); + Interfaces.note(thisJoinPoint.getSignature().toShortString()+"-!I||A*"); } - + // The staticField in I has no 'target()' for this pointcut, it shouldn't match anything if things are working properly before(I i): within(I) && set(String I.*) && target(i) { - Interfaces.note(thisJoinPoint.getSignature().getName()+"-I"); //toShortString()); + Interfaces.note(thisJoinPoint.getSignature().getName()+"-I"); } before(I i): within(A*) && set(String I.*) && target(i) { - Interfaces.note(thisJoinPoint.getSignature().getName()+"-A*"); //toShortString()); + Interfaces.note(thisJoinPoint.getSignature().getName()+"-A*"); } before(I i): initialization(I.new(..)) && target(i) { diff --git a/tests/design/intro/Within.java b/tests/design/intro/Within.java index 49021c1f0..3119f1d1e 100644 --- a/tests/design/intro/Within.java +++ b/tests/design/intro/Within.java @@ -1,15 +1,15 @@ +import org.aspectj.lang.annotation.SuppressAjWarnings; import org.aspectj.testing.Tester; - public class Within { public static void main(String[] args) { - C c = new C(); - c.mi(); - - Tester.check("I.mi within A1"); - Tester.check("I.mi instanceof C"); - Tester.check("I.mi instanceof I"); - - c.mc(); + C c = new C(); + c.mi(); + + Tester.check("I.mi within A1"); + Tester.check("I.mi instanceof C"); + Tester.check("I.mi instanceof I"); + + c.mc(); } } @@ -31,34 +31,34 @@ aspect A2 { aspect Test { - before (): execution(* I.*(..)) && within(C) { - Tester.checkFailed(thisJoinPoint + " I.* within C"); + @SuppressAjWarnings("adviceDidNotMatch") before(): execution(* I.*(..)) && within(C) { + Tester.checkFailed(thisJoinPoint + " I.* within C"); } - before (): execution(* I.*(..)) && within(I) { - Tester.checkFailed(thisJoinPoint + " I.* within I"); + @SuppressAjWarnings("adviceDidNotMatch") before (): execution(* I.*(..)) && within(I) { + Tester.checkFailed(thisJoinPoint + " I.* within I"); } before (): execution(* I.*(..)) && within(A1) { - Tester.checkEqual(thisJoinPoint.getSignature().getName(), "mi", + Tester.checkEqual(thisJoinPoint.getSignature().getName(), "mi", thisJoinPoint + " I.* within A1"); - Tester.note("I.mi within A1"); + Tester.note("I.mi within A1"); } - before (): execution(* I.*(..)) && within(A2) { + @SuppressAjWarnings("adviceDidNotMatch") before (): execution(* I.*(..)) && within(A2) { } before (): execution(* I.*(..)) && this(C) { - Tester.checkEqual(thisJoinPoint.getSignature().getName(), "mi", + Tester.checkEqual(thisJoinPoint.getSignature().getName(), "mi", thisJoinPoint + " I.* instanceof C"); - Tester.note("I.mi instanceof C"); + Tester.note("I.mi instanceof C"); } before (): execution(* I.*(..)) && this(I) { - Tester.checkEqual(thisJoinPoint.getSignature().getName(), "mi", + Tester.checkEqual(thisJoinPoint.getSignature().getName(), "mi", thisJoinPoint + " I.* instanceof I"); - Tester.note("I.mi instanceof I"); + Tester.note("I.mi instanceof I"); } before (): execution(* I.*(..)) && this(A1) { - Tester.checkFailed(thisJoinPoint + " I.* instanceof A1"); + Tester.checkFailed(thisJoinPoint + " I.* instanceof A1"); } before (): execution(* I.*(..)) && this(A2) { - Tester.checkFailed(thisJoinPoint + " I.* instanceof A2"); + Tester.checkFailed(thisJoinPoint + " I.* instanceof A2"); } } diff --git a/tests/design/reflect/Coverage.java b/tests/design/reflect/Coverage.java index 7de997909..d0e58255b 100644 --- a/tests/design/reflect/Coverage.java +++ b/tests/design/reflect/Coverage.java @@ -179,9 +179,9 @@ aspect JoinPoints extends Helper { Throwable t = null; try { t = (Throwable)jp.getArgs()[0]; - } catch (ArrayIndexOutOfBoundsException _) { + } catch (ArrayIndexOutOfBoundsException _x) { a("handlers out of bounds"); - } catch (ClassCastException __) { + } catch (ClassCastException __x) { a(ni(jp.getArgs()[0], Throwable.class, "handlers")); } a(t.getMessage(), "test"); |