diff options
author | aclement <aclement> | 2004-08-11 12:24:27 +0000 |
---|---|---|
committer | aclement <aclement> | 2004-08-11 12:24:27 +0000 |
commit | 64183c38266114bce7aa60ff743b4b9eda5cbe2d (patch) | |
tree | 4b4b805e6199b1d8817cfbf0f592fe9adadba7ba /tests/bugs | |
parent | 065228643beb192e3214a032c2b62f90db4f8592 (diff) | |
download | aspectj-64183c38266114bce7aa60ff743b4b9eda5cbe2d.tar.gz aspectj-64183c38266114bce7aa60ff743b4b9eda5cbe2d.zip |
Fix and tests for Bugzilla Bug 68991
intertype initialisers should match field set pointcuts
Diffstat (limited to 'tests/bugs')
-rw-r--r-- | tests/bugs/PR68991/Oxford.java | 45 | ||||
-rw-r--r-- | tests/bugs/PR68991/Simple.java | 58 |
2 files changed, 103 insertions, 0 deletions
diff --git a/tests/bugs/PR68991/Oxford.java b/tests/bugs/PR68991/Oxford.java new file mode 100644 index 000000000..c22cceac6 --- /dev/null +++ b/tests/bugs/PR68991/Oxford.java @@ -0,0 +1,45 @@ +/* initialisers of intertype fields should match field set pointcuts. + +In the example below, the output should be + +set field set(int C.n) +set field set(int C.m) +get field get(int C.n) +set field set(int C.n) + +but the first field set (of C.n) is not picked up. +*/ + + + +aspect Aspect { + + + private int C.n = 13; + + before() : get(* C.*) { + System.err.print(":get field "+thisJoinPointStaticPart); + } + + before() : set(* C.*) { + System.err.print(":set field "+thisJoinPointStaticPart); + } + + public void C.foo() { + n++; + } + +} + +class C { + int m = 20; +} + +public class Oxford { + + public static void main(String[] args) { + C c = new C(); + c.foo(); + } + +}
\ No newline at end of file diff --git a/tests/bugs/PR68991/Simple.java b/tests/bugs/PR68991/Simple.java new file mode 100644 index 000000000..f6afa8e10 --- /dev/null +++ b/tests/bugs/PR68991/Simple.java @@ -0,0 +1,58 @@ +import java.util.*; + +aspect Aspect { + + public static List tjps = new ArrayList(); + public static List values = new ArrayList(); + public static List ejps = new ArrayList(); + + public int C.m = 13; + private int C.n = 13; + + before() : get(* C.*) { + tjps.add(thisJoinPointStaticPart.toString()); + ejps.add(thisEnclosingJoinPointStaticPart.toString()); + //System.out.println("get field "+thisJoinPointStaticPart); + } + + before(int x) : set(* C.*) && args(x) { + tjps.add(thisJoinPointStaticPart.toString()); + ejps.add(thisEnclosingJoinPointStaticPart.toString()); + values.add(new String(thisJoinPointStaticPart+"="+new Integer(x))); + //System.err.println("set field "+thisJoinPointStaticPart); + } + + public void C.foo() { + m++; + n++; + } + +} + +class C { + // int m = 20; +} + +public class Simple { + + public static void main(String[] args) { + C c = new C(); + c.foo(); + System.err.println("\nSummaryJPs:"+Aspect.tjps); + System.err.println("\nSummaryEJPs:"+Aspect.ejps); + System.err.println("\nSummaryVals:"+Aspect.values); + // Ought to have a nicer signature for the ejpsp in the case of an initializer ... + chkNext(Aspect.tjps,"set(int C.m)");chkNext(Aspect.values,"set(int C.m)=13");chkNext(Aspect.ejps,"execution(void Aspect.ajc$interFieldInit$Aspect$C$m(C))"); + chkNext(Aspect.tjps,"set(int C.n)");chkNext(Aspect.values,"set(int C.n)=13");chkNext(Aspect.ejps,"execution(void Aspect.ajc$interFieldInit$Aspect$C$n(C))"); + chkNext(Aspect.tjps,"get(int C.m)"); chkNext(Aspect.ejps,"execution(void C.foo())"); + chkNext(Aspect.tjps,"set(int C.m)");chkNext(Aspect.values,"set(int C.m)=14");chkNext(Aspect.ejps,"execution(void C.foo())"); + chkNext(Aspect.tjps,"get(int C.n)"); chkNext(Aspect.ejps,"execution(void C.foo())"); + chkNext(Aspect.tjps,"set(int C.n)");chkNext(Aspect.values,"set(int C.n)=14");chkNext(Aspect.ejps,"execution(void C.foo())"); + } + + public static void chkNext(List l,String expected) { + String s = (String)l.remove(0); + if (!s.equals(expected)) throw new RuntimeException("Expected next thing on list to be '"+expected+"' but it was '"+s+"'"); + } + +}
\ No newline at end of file |