aboutsummaryrefslogtreecommitdiffstats
path: root/tests/design
diff options
context:
space:
mode:
Diffstat (limited to 'tests/design')
-rw-r--r--tests/design/eachobject/Tricky3.java15
-rw-r--r--tests/design/intro/Interfaces.java70
-rw-r--r--tests/design/intro/Within.java44
-rw-r--r--tests/design/reflect/Coverage.java4
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");