diff options
author | wisberg <wisberg> | 2002-12-16 17:58:19 +0000 |
---|---|---|
committer | wisberg <wisberg> | 2002-12-16 17:58:19 +0000 |
commit | d842c4f1139629c1f062b74ba818d233b2c31043 (patch) | |
tree | 842d3871620bc0eb60edcd95e55804d67e0f61fa /org.aspectj.ajdt.core/testdata/src1 | |
parent | 3ce247199704eae6b2c92c6e38c69584e3250c52 (diff) | |
download | aspectj-d842c4f1139629c1f062b74ba818d233b2c31043.tar.gz aspectj-d842c4f1139629c1f062b74ba818d233b2c31043.zip |
initial version
Diffstat (limited to 'org.aspectj.ajdt.core/testdata/src1')
39 files changed, 1068 insertions, 0 deletions
diff --git a/org.aspectj.ajdt.core/testdata/src1/.cvsignore b/org.aspectj.ajdt.core/testdata/src1/.cvsignore new file mode 100644 index 000000000..c06bd3c77 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/.cvsignore @@ -0,0 +1,2 @@ +*~ +*.class diff --git a/org.aspectj.ajdt.core/testdata/src1/A.java b/org.aspectj.ajdt.core/testdata/src1/A.java new file mode 100644 index 000000000..9be597f7e --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/A.java @@ -0,0 +1,41 @@ +public aspect A issingleton() { + public void m(int x) { + System.out.println(x); + } + + pointcut foo(String[] args): I.foo(args) && execution(void Hello.*(..)); + + ///XXX add a test for this correctly + //XXXpublic int Hello.fromA; + + before(): execution(* Hello.*(..)) { + System.out.println("enter"); + } + + + public void pingHello(Hello h) { + int x = 2; + System.out.println(x); + } + + public static void main(String[] args) { + Hello.main(args); + } +} + +class Hello { + public static void main(String[] args) { + } +} + + +interface I { + pointcut foo(String[] i): args(i); + + static aspect InnerA { + before(): this(String) { + System.out.println("hi"); + } + } + //void foo(); +} diff --git a/org.aspectj.ajdt.core/testdata/src1/A1.java b/org.aspectj.ajdt.core/testdata/src1/A1.java new file mode 100644 index 000000000..7f82c3631 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/A1.java @@ -0,0 +1,23 @@ +aspect A1 { + after() throwing (Throwable t): execution(* Hello.*(..)) { + System.out.println("enter"); + } + + after() throwing: execution(* Hello.*(..)) { + System.out.println("enter"); + } + + after() returning: execution(* Hello.*(..)) { + System.out.println("enter"); + } + + after(): execution(void Hello.*ai*(..)) { + } +} + + +class Hello { + public static void main(String[] args) { + System.out.println("hello"); + } +} diff --git a/org.aspectj.ajdt.core/testdata/src1/A2.java b/org.aspectj.ajdt.core/testdata/src1/A2.java new file mode 100644 index 000000000..c8fd65aa7 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/A2.java @@ -0,0 +1,19 @@ +aspect A2 { + after(Object thisObject): target(thisObject) && execution(public * Hello.*(..)) { + } + after(Object thisObject): this(thisObject) && execution(* Hello.*(..)) { + System.out.println(thisObject); + } + after() returning (String s): execution(* Hello.*(..)) { + //System.out.println(s); + } +} + +class Hello { + public static void main(String[] args) { + System.out.println("hello"); + } + + void m() { + } +} diff --git a/org.aspectj.ajdt.core/testdata/src1/Ap.java b/org.aspectj.ajdt.core/testdata/src1/Ap.java new file mode 100644 index 000000000..9975367cf --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/Ap.java @@ -0,0 +1,51 @@ +package src1; + +aspect Ap { + public void m(int x) { + System.out.println(x); + } + + pointcut foo(String[] args): args(args) && execution(void Hello.*(..)); + + //pointcut ref(): foo12(); + + before(): execution(* Hello.*(..)) { + System.out.println("enter"); + } + +// before(): get(* java.lang.System.out) { +// System.out.println("exit get"); +// } + + public int Hello.fromA; + + public void pingHello(Hello h) { + int x = 2; //XXXh.fromA; + System.out.println(x); + } + +// after(): abc { +// System.out.println("enter"); +// } +// after() throwing (Throwable t): abc { +// System.out.println("enter"); +// } + +// public int Hello.m() { +// System.out.println("m()"); +// return 10; +// } + +// void around(int x): abc { +// System.out.println("enter"); +// } +} + +class Hello { + public static void main(String[] args) { + } +} + +interface I { + //void foo(); +} diff --git a/org.aspectj.ajdt.core/testdata/src1/AroundA.java b/org.aspectj.ajdt.core/testdata/src1/AroundA.java new file mode 100644 index 000000000..8bc7b2f93 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/AroundA.java @@ -0,0 +1,27 @@ +aspect AroundA { + pointcut foo(): execution(void main(..)); + + int around(int i, boolean b): args(i, b) && foo() { + System.out.println("enter"); + return proceed(10, false); + } + + + void around(Object a): args(a) && foo() { + System.out.println("enter"); + proceed("new: " + a); + System.out.println("exit"); + } + + void around(final String[] a): args(a) && foo() { + Runnable r = new Runnable() { + public void run() { + proceed(a); + } + }; + r.run(); + r.run(); + } +} + +
\ No newline at end of file diff --git a/org.aspectj.ajdt.core/testdata/src1/AroundA1.java b/org.aspectj.ajdt.core/testdata/src1/AroundA1.java new file mode 100644 index 000000000..8230a80e0 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/AroundA1.java @@ -0,0 +1,45 @@ +public class AroundA1 { + + public static void main(String[] args) { + System.err.println(new AroundA1().main(3, (short)1, true)); + } + + public int main(int xx, short s, boolean yy) { + System.err.println(xx); + System.err.println(s); + System.err.println(yy); + return 10; + } +} + +aspect MyAroundAspect { + int field = 10; + + pointcut foo(): call(int main(..)); + + Object around(AroundA1 o, int i, boolean b): target(o) && args(i, *, b) && foo() { + System.err.println("enter: " + o + " with " + field); + Object x = proceed(o, 10, false); + System.err.println("got: " + x); + return new Integer(42); + } + + +// void around(Object a): args(a) && foo() { +// System.out.println("enter"); +// proceed("new: " + a); +// System.out.println("exit"); +// } +// +// void around(final String[] a): args(a) && foo() { +// Runnable r = new Runnable() { +// public void run() { +// proceed(a); +// } +// }; +// r.run(); +// r.run(); +// } +} + +
\ No newline at end of file diff --git a/org.aspectj.ajdt.core/testdata/src1/BadA.java b/org.aspectj.ajdt.core/testdata/src1/BadA.java new file mode 100644 index 000000000..2529297e9 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/BadA.java @@ -0,0 +1,35 @@ +aspect BadA { + public void m(int x) { + System.out.println(x); + } + +// pointcut foo(): execution(void Hello.*(..)); + pointcut foo1(): abc); + pointcut foo2(): abc ; + + + +// pointcut bar(): this(Bazoo); + + //pointcut foo2(): abc; + //pointcut foo3(): abc; + +// before(): abc { +// System.out.println("enter"); +// } +// after(): abc { +// System.out.println("enter"); +// } +// after() throwing (Throwable t): abc { +// System.out.println("enter"); +// } + +// public int Hello.m() { +// System.out.println("m()"); +// return 10; +// } + +// void around(int x): abc { +// System.out.println("enter"); +// } +} diff --git a/org.aspectj.ajdt.core/testdata/src1/BadBinding.java b/org.aspectj.ajdt.core/testdata/src1/BadBinding.java new file mode 100644 index 000000000..33545b414 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/BadBinding.java @@ -0,0 +1,22 @@ +aspect A2 { + after(Object thisObject1): target(thisObject) { // ERR unbound + } + after(Object o1, Object o2): target(o1) || target(o2) { // ERR inconsistent + } + after(Object o1, Object o2): target(o1) && target(o2) { // NO PROB + } + after(Object o1): target(o1) && target(o1) { // ERR multiple + } + after(Object o1): !target(o1) { // ERR can't bind here + } + void around(Object o1): target(o1) { + proceed(2); //ERR can't convert from int to Object + } + void around(Object o1): target(o1) { + proceed(null, 2); //ERR wrong number of args + } + void around(Object o1): target(o1) { + proceed(); //ERR wrong number of args + } + +} diff --git a/org.aspectj.ajdt.core/testdata/src1/BadHello.java b/org.aspectj.ajdt.core/testdata/src1/BadHello.java new file mode 100644 index 000000000..504e82815 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/BadHello.java @@ -0,0 +1,6 @@ +public class BadHello { + public static void main(String[] args) { + new BadHello().m(); + } + public void m() { return 2; } +} diff --git a/org.aspectj.ajdt.core/testdata/src1/DeclareSoft.java b/org.aspectj.ajdt.core/testdata/src1/DeclareSoft.java new file mode 100644 index 000000000..b42a82453 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/DeclareSoft.java @@ -0,0 +1,26 @@ +import java.io.*; +import org.aspectj.lang.*; + +public class DeclareSoft { + public static void main(String[] args) { + try { + new DeclareSoft().m(); + } catch (SoftException se) { + return; + } + } + + void m() { + InputStream s = new FileInputStream("foobar"); + s.close(); + } +} + + +aspect A { + //declare soft: IOException: execution(void m()); + + declare soft: IOException: foo(); + + pointcut foo(): execution(void m()); +} diff --git a/org.aspectj.ajdt.core/testdata/src1/DeclareWarning.java b/org.aspectj.ajdt.core/testdata/src1/DeclareWarning.java new file mode 100644 index 000000000..0c6ecf6b1 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/DeclareWarning.java @@ -0,0 +1,11 @@ +public class DeclareWarning { + public void m() { // should be error on this line + } +} + +aspect Checker { + declare warning: execution(* m()): "too short method name"; + declare warning: execution(* n()): "too short method name"; // no effect +} + + diff --git a/org.aspectj.ajdt.core/testdata/src1/Declares.java b/org.aspectj.ajdt.core/testdata/src1/Declares.java new file mode 100644 index 000000000..b3c6a065b --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/Declares.java @@ -0,0 +1,13 @@ +public class Declares { + public void m() { // should be error on this line + } +} + +aspect Checker { + declare error: execution(* m()): "too short method name"; + declare error: execution(* n()): "too short method name"; // no effect + + //declare warning: exec: "bar"; +} + + diff --git a/org.aspectj.ajdt.core/testdata/src1/DummyAspect.java b/org.aspectj.ajdt.core/testdata/src1/DummyAspect.java new file mode 100644 index 000000000..dafef6e64 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/DummyAspect.java @@ -0,0 +1,6 @@ +public abstract aspect DummyAspect { + public abstract pointcut traced(Object o); + + before (Object exc): traced(exc) { + } +} diff --git a/org.aspectj.ajdt.core/testdata/src1/Good.java b/org.aspectj.ajdt.core/testdata/src1/Good.java new file mode 100644 index 000000000..f21b04c6b --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/Good.java @@ -0,0 +1,61 @@ + +import java.util.*; +import java.io.IOException; + +public class Good { + + public static String foo; + public int publicA = 1; + private int privateA = 2; + protected int protectedA = 3; + int packageA = 4; + + { publicA = 5; } + + static { foo = "hi"; } + + public Good() { } + + public void foo() { + int i = 0; + i += 1; + i += 2; + + int aspect = 2; + + System.out.println(1 + aspect +", " + aspect++); + } + + { publicA = 6; } + + + static aspect x { } +} + +aspect A { + public void m() { } +} + +/* + +aspect A { + int j; + + public void m() { } + + pointcut all(): call(* *(..)); + + after all(): { System.out.println(""); } + + before(): call(* *(..)) { + System.out.println(""); + } +} + +interface I { } +*/ + +//privileged aspect PrivilegedAspect { } + + + diff --git a/org.aspectj.ajdt.core/testdata/src1/Handler.java b/org.aspectj.ajdt.core/testdata/src1/Handler.java new file mode 100644 index 000000000..bcb88d7e6 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/Handler.java @@ -0,0 +1,50 @@ +public class Handler { + public static void main(String[] args) { + m(); + } + +// public static void m() { +// while(true) { +// foo: {try { +// int x = 2+3; +// if (x >3) break foo; +// x = x+10; +// //return; +// } catch (Throwable t) { +// System.err.println(t); +// }} +// System.out.println("still in loop"); +// } +// //System.out.println("outside"); +// +// } + + public static void m() { + try { + int x = 0; + int y = 3/x; + throw new RuntimeException("shouldn't be here"); + } catch (Throwable t) { + return; + } + } + + public void m1(int x) { + boolean b = true; + if (b) { + m(); + } else { + m(); + } + } +} + +aspect A { + before(Throwable t): handler(Throwable) && args(t) { + System.out.println("caught " + t + " at " + thisJoinPointStaticPart); + } + +// before(int i): cflow(execution(void m1(int)) && args(i)) && call(void m()) { +// System.out.println("i"); +// } +}
\ No newline at end of file diff --git a/org.aspectj.ajdt.core/testdata/src1/Hello.java b/org.aspectj.ajdt.core/testdata/src1/Hello.java new file mode 100644 index 000000000..9af032526 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/Hello.java @@ -0,0 +1,5 @@ +public class Hello { + public static void main(String[] args) { + System.out.println("hello world"); + } +} diff --git a/org.aspectj.ajdt.core/testdata/src1/IfPcd.java b/org.aspectj.ajdt.core/testdata/src1/IfPcd.java new file mode 100644 index 000000000..4318f3d41 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/IfPcd.java @@ -0,0 +1,37 @@ +public aspect IfPcd { + private static int foo = 393; + + before(): execution(void IfPcd.main(..)) && if(foo == 393) { + System.err.println("Hiya"); + foo++; + main(null); // saved from an infinite loop by the if + } + + before(): execution(void IfPcd.main(..)) && if(thisJoinPoint.getThis() == null) { + System.err.println("!has this: "+ thisJoinPoint.getThis()); + } + + before(): execution(void IfPcd.main(..)) && if(thisJoinPointStaticPart.getKind() == "method-execution") { + System.err.println("is method-exec"); + } + + + before(Object o): execution(void IfPcd.main(..)) && args(o) && if(o != null) { + System.err.println("got: " + o); + } + + pointcut fun(Object o): args(o) && if(o != null); + + before(Object o1, Object o2): execution(void IfPcd.main(..)) && args(o1) && fun(o2) { + System.err.println("got: " + o2); + } + + before(): execution(void IfPcd.main(..)) && fun(Object) { + System.err.println("got nothin"); + } + + public static void main(String[] args) { + System.err.println("actual body: " + args); + } +} + diff --git a/org.aspectj.ajdt.core/testdata/src1/Initialization.java b/org.aspectj.ajdt.core/testdata/src1/Initialization.java new file mode 100644 index 000000000..4b738a975 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/Initialization.java @@ -0,0 +1,46 @@ +public class Initialization extends Super { + public static void main(String[] args) { + new Initialization(); + new Initialization(331); + } + + Initialization() { + this(98); + } + Initialization(int i) { + super(i+1); + foo(i); + } + + static void foo(int i) { + System.out.println("running foo with " + i); + } +} + +class Super { + Super(int i) { + } +} + +aspect Foo { + + +// void around(int i): initialization(Initialization.new(int)) && args(i) { +// System.out.println(thisJoinPoint); +// System.out.println(java.util.Arrays.asList(thisJoinPoint.getArgs())); +// proceed(993); +// } +// + + + Object around(): preinitialization(Initialization.new()) { + System.out.println("i"); + return null; + } + +// before(int i): execution(Initialization.new(int)) && args(i) { +// System.err.println(i); +// } +} + + diff --git a/org.aspectj.ajdt.core/testdata/src1/InterType.java b/org.aspectj.ajdt.core/testdata/src1/InterType.java new file mode 100644 index 000000000..af51afb11 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/InterType.java @@ -0,0 +1,86 @@ +import junit.framework.Assert; + +public class InterType { + + public static void main(String[] args) { + Target t = new Target(); + Assert.assertEquals(0, t.i); + t.i = 37; + Assert.assertEquals(37, t.i); + Assert.assertEquals(37, t.i++); + Assert.assertEquals(38, t.i); + Assert.assertEquals(39, ++t.i); + Assert.assertEquals(39, t.i); + + System.out.println("t.i = " + t.i); + + Assert.assertEquals(0, ((I)t).i); + + Assert.assertEquals("foo", t.s); + t.s += "-bar"; + Assert.assertEquals("foo-bar", t.s); + System.out.println("t.s = " + t.s); + + // this captures an interesting property of initializers: + // that introduced inits run before non-introduced inits + Assert.assertEquals("inst00onA", A.getInstS(t)); + System.out.println("t.instS = " + A.getInstS(t)); + + I i = t; + Assert.assertEquals("dummy", i.myString); + i.myString = "foo"; + Assert.assertEquals(i.myString, "foo"); + System.out.println("t.myString = " + t.myString); + + Assert.assertNotNull(A.aspectOf()); + Assert.assertEquals(A.aspectOf(), A.aspectOf()); + Assert.assertTrue(A.hasAspect()); + + //XXX don't handle constants +// int x = 10; +// switch(x) { +// case Target.CONST: break; +// default: Assert.fail("bad switch"); +// } + + } +} + +class Target implements I { + public int j = 2; + private boolean instS = true; // potential conflict need to handle gracefully + public boolean getInstS() { return instS; } + + String conflict = "boo"; +} + +class SubTarget extends Target { + public static String foo() { + return A.aspectOf().toString(); + } +} + + +interface I { } + + + +aspect A { + private static String aStatic = "onA"; + + public int Target.foobarvas = 0; + public int I.i = 0; + public int Target.i; + public static String Target.s = "foo"; + public static int Target.CONST = 10; + + private String Target.instS = "inst" + j + this.j + aStatic; + + //private String Target.conflict = "goo"; error + + public static String getInstS(Target t) { + return t.instS; + } + + public String I.myString = "dummy"; +} diff --git a/org.aspectj.ajdt.core/testdata/src1/InterTypeConstructors.java b/org.aspectj.ajdt.core/testdata/src1/InterTypeConstructors.java new file mode 100644 index 000000000..d11f3bf4d --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/InterTypeConstructors.java @@ -0,0 +1,73 @@ +import junit.framework.Assert; + +public class InterTypeConstructors { + + public static void main(String[] args) { + Target t = A.makeT(); + } +} + +class Target implements I { + private Target(String s) { + System.err.println(s); + } + + public Target() { + this(10); + } + + int f = 10; + static int ss() { return 100; } + + String getS() { return "Target" + this.instS("Foo"); } + + private int instS(String s) { return 10; } + + public int mmmm() { System.err.println("noarg"); return 3;} + +} + +class C { + class SubTarget extends Target { + final String s; + + public SubTarget() { + super(10); + s = "hi"; + } + } +} + +//class SubTarget extends Target { +// String getS() { return "SubTarget"; } +// static int ss() { return 10; } +// +// public void foobar() { +// mmmm(333); +// } +// +// //public int mmmm(int x) { return x; } +//} + +interface SuperI {} + + +interface I extends SuperI { } + + + +aspect A { + public static Target makeT() { + return new Target(10); + } + + Target.new(int foo) { + this("hi" + ++foo); + this.f = mmmm() + foo; + System.err.println(f == 14); + } + + //C.SubTarget.new(String value) { // uncomment for an error + //this.s = value; + //} +} diff --git a/org.aspectj.ajdt.core/testdata/src1/InterTypeMethods.java b/org.aspectj.ajdt.core/testdata/src1/InterTypeMethods.java new file mode 100644 index 000000000..4bc44186c --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/InterTypeMethods.java @@ -0,0 +1,79 @@ +import junit.framework.Assert; + +public class InterTypeMethods { + + public static void main(String[] args) { + Target t = new Target(); + Assert.assertEquals(23, t.instM(1)); + Assert.assertEquals("foo10", A.instS(t, "foo")); + + System.out.println("t: " + t); + + Assert.assertEquals(12, SubTarget.staticM()); + + SubTarget st = new SubTarget(); + + Assert.assertEquals("100Target10", st.foo()); + + st.foobar(); + t.mmmm(2); + + Assert.assertEquals("xyz-foo", st.onI("xyz-")); + } +} + +class Target implements I { + int f = 10; + static int ss() { return 100; } + + String getS() { return "Target" + this.instS("Foo"); } + + private int instS(String s) { return 10; } + + public int mmmm() { System.err.println("noarg"); return 3;} + +} + +class SubTarget extends Target { + String getS() { return "SubTarget"; } + static int ss() { return 10; } + + public void foobar() { + mmmm(333); + } + + //public int mmmm(int x) { return x; } +} + +interface SuperI {} + + +interface I extends SuperI { } + + + +aspect A { + public static String instS(Target t, String s) { + return t.instS(s); + } + + public int Target.instM(int x) { return x+2 + f + this.f; } + private String Target.instS(String s) { return s + this.f; } + + static int SubTarget.staticM() { return ss() + 2; } + + public String SubTarget.foo() { return super.ss() + super.getS(); } + + public int Target.mmmm(int i) { System.err.println("onearg"); return 3;} + public int SubTarget.mmmm(int i) { System.err.println("onearg on Sub"); return 4;} + + public String I.v = "foo"; + + public String I.onI(String a) { + return a + v; + } + + public String SuperI.onI(String a) { + return a + "Super"; + } +} diff --git a/org.aspectj.ajdt.core/testdata/src1/MyTrace.java b/org.aspectj.ajdt.core/testdata/src1/MyTrace.java new file mode 100644 index 000000000..a4b556436 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/MyTrace.java @@ -0,0 +1,7 @@ +aspect MyTrace extends Trace { + public pointcut traced(Object foo): this(foo) && execution(* doit(..)); + + after(Object o) returning (Object ret): traced(o) { + System.out.println("exit: " /*+ thisJoinPoint.getSignature()*/ + " with " + ret); + } +}
\ No newline at end of file diff --git a/org.aspectj.ajdt.core/testdata/src1/Parents.java b/org.aspectj.ajdt.core/testdata/src1/Parents.java new file mode 100644 index 000000000..17f071927 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/Parents.java @@ -0,0 +1,40 @@ +public class Parents { + public static void main(String[] args) { + A.I i = new C1(); + i.m(); + + C2 c2 = new C2(); + c2.m1(); + + A.C3 c3 = (A.C3)c2; + + C4 c4 = new C4(); + c4.m4(); + } +} + +class C1 { + public void m() { System.out.println("m"); } +} + +class C2 {} + +class C4 {} + +aspect A { + static class C3 { + public void m1() { System.out.println("from C3"); } + } + + interface I { + void m(); + } + + declare parents: (C1 && !C2) implements I; + declare parents: C2 extends C3; + + interface I4 {} + public void I4.m4() { System.out.println("I.m4"); } + + declare parents: C4 implements I4; +}
\ No newline at end of file diff --git a/org.aspectj.ajdt.core/testdata/src1/ParentsFail.java b/org.aspectj.ajdt.core/testdata/src1/ParentsFail.java new file mode 100644 index 000000000..745fb67c9 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/ParentsFail.java @@ -0,0 +1,22 @@ +public class ParentsFail { + public static void main(String[] args) { + I i = new C1(); // CE incompatible + i.m(); + } +} + +class C1 { + public void m() { System.out.println("m"); } +} +class C2 {} +class C3 extends C2 {} +interface I { + void m(); +} + +aspect A { + declare parents: C2 implements I; // CE can't implement + declare parents: C2 extends C3; // CE circular + + declare parents: C1 extends C1; // CE self +}
\ No newline at end of file diff --git a/org.aspectj.ajdt.core/testdata/src1/PerCflow.java b/org.aspectj.ajdt.core/testdata/src1/PerCflow.java new file mode 100644 index 000000000..9606c1f75 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/PerCflow.java @@ -0,0 +1,22 @@ +public class PerCflow { + public static void main(String[] args) { + m(); + } + + static void m() { + System.out.println("m()"); + } +} + + +aspect A percflow(pc()) { + pointcut pc(): execution(void main(..)); + static Object o = new Integer(2); + before(): execution(void m()) { + System.out.println("in " + o.toString()); + } + + static { + o = "hello"; + } +}
\ No newline at end of file diff --git a/org.aspectj.ajdt.core/testdata/src1/PerObject.java b/org.aspectj.ajdt.core/testdata/src1/PerObject.java new file mode 100644 index 000000000..9452ed28a --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/PerObject.java @@ -0,0 +1,22 @@ +public class PerObject { + public static void main(String[] args) { + new PerObject().m(); + } + + void m() { + System.out.println("m()"); + } +} + + +aspect A perthis(pc()) { + pointcut pc(): this(PerObject) && execution(* m(..)); + static Object o = new Integer(2); + before(): get(* *) { + System.out.println("in " + o.toString()); + } + + static { + o = "hello"; + } +}
\ No newline at end of file diff --git a/org.aspectj.ajdt.core/testdata/src1/Privileged.java b/org.aspectj.ajdt.core/testdata/src1/Privileged.java new file mode 100644 index 000000000..064f1c755 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/Privileged.java @@ -0,0 +1,32 @@ +import java.io.*; +import org.aspectj.lang.*; + +public class Privileged { + public static void main(String[] args) { + Privileged p = new Privileged(); + + System.out.println("got: " + A.getX(p)); + System.out.println("s: " + s); + } + + private int m() { + return 2; + } + + private int x = 1; + + private static String s = "hi"; +} + + +privileged aspect A { + static int getX(Privileged p) { + Runnable r = new Runnable() { + public void run() { + Privileged.s += 10; + } + }; + r.run(); + return p.x + p.m(); + } +} diff --git a/org.aspectj.ajdt.core/testdata/src1/ThisAndModifiers.java b/org.aspectj.ajdt.core/testdata/src1/ThisAndModifiers.java new file mode 100644 index 000000000..c8fd65aa7 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/ThisAndModifiers.java @@ -0,0 +1,19 @@ +aspect A2 { + after(Object thisObject): target(thisObject) && execution(public * Hello.*(..)) { + } + after(Object thisObject): this(thisObject) && execution(* Hello.*(..)) { + System.out.println(thisObject); + } + after() returning (String s): execution(* Hello.*(..)) { + //System.out.println(s); + } +} + +class Hello { + public static void main(String[] args) { + System.out.println("hello"); + } + + void m() { + } +} diff --git a/org.aspectj.ajdt.core/testdata/src1/Trace.java b/org.aspectj.ajdt.core/testdata/src1/Trace.java new file mode 100644 index 000000000..d6aaf17f8 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/Trace.java @@ -0,0 +1,22 @@ +public abstract aspect Trace { + public abstract pointcut traced(Object o); + + before (Object exc): traced(exc) { + System.out.println("enter: " /*+ thisJoinPoint.getSignature()*/); + } + + Object around(): execution(* doit(..)) { + Object exc = "Hi"; + System.out.println("start around: " + exc); + Object ret = proceed(); + System.out.println("exiting around with: " + ret); + return ret; + } + + Object around(Object exc): traced(exc) { + System.out.println("start around(2): " + exc); + Object ret = proceed(exc); + System.out.println("exiting around with(2): " + ret); + return ret; + } +} diff --git a/org.aspectj.ajdt.core/testdata/src1/TraceHello.java b/org.aspectj.ajdt.core/testdata/src1/TraceHello.java new file mode 100644 index 000000000..545c58ccc --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/TraceHello.java @@ -0,0 +1,5 @@ +public aspect TraceHello { + before(): execution(* Hello.*(..)) { + System.out.println("entering: " + thisJoinPoint); + } +}
\ No newline at end of file diff --git a/org.aspectj.ajdt.core/testdata/src1/UnimplementedSyntax.java b/org.aspectj.ajdt.core/testdata/src1/UnimplementedSyntax.java new file mode 100644 index 000000000..3ea1a1685 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/UnimplementedSyntax.java @@ -0,0 +1,23 @@ +/** + * + * + */ +aspect A dominates Foo persingleton() { } + +//aspect B perthis(foo()) { +//XXX don't forget an error test for foo() not found} + +aspect C { + pointcut w(int x): args(x) && if(x < 10); + pointcut x(): cflow(y()); + pointcut y(): withincode(int m()); + + pointcut z(): execution(void m()) a b c; + declare error: execution(void m()): "hi" ac; + + pointcut p(): handler(Foo); + + pointcut p2(): initialization(Object.new(..)); +} + +aspect D a b c {}
\ No newline at end of file diff --git a/org.aspectj.ajdt.core/testdata/src1/Xlint.java b/org.aspectj.ajdt.core/testdata/src1/Xlint.java new file mode 100644 index 000000000..bec51c6d3 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/Xlint.java @@ -0,0 +1,3 @@ +public aspect Xlint { + pointcut foo(): this(NotFoundType); +}
\ No newline at end of file diff --git a/org.aspectj.ajdt.core/testdata/src1/p1/.cvsignore b/org.aspectj.ajdt.core/testdata/src1/p1/.cvsignore new file mode 100644 index 000000000..6b468b62a --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/p1/.cvsignore @@ -0,0 +1 @@ +*.class diff --git a/org.aspectj.ajdt.core/testdata/src1/p1/A.java b/org.aspectj.ajdt.core/testdata/src1/p1/A.java new file mode 100644 index 000000000..be6b96b2f --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/p1/A.java @@ -0,0 +1,28 @@ +aspect A { + public void m(int x) { + System.out.println(x); + } + + pointcut foo(String[] args): args(args) && execution(void Hello.*(..)); + + before(): execution(* Hello.*(..)) { + System.out.println("enter"); + } + + public int Hello.fromA; + + public void pingHello(Hello h) { + int x = 2; + System.out.println(x); + } + +} + +class Hello { + public static void main(String[] args) { + } +} + +interface I { + //void foo(); +} diff --git a/org.aspectj.ajdt.core/testdata/src1/p1/Foo.java b/org.aspectj.ajdt.core/testdata/src1/p1/Foo.java new file mode 100644 index 000000000..0a0b8b22a --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/p1/Foo.java @@ -0,0 +1,7 @@ +package p1; + +public class Foo { + public static void main(String[] args) { + System.out.println("Foo"); + } +} diff --git a/org.aspectj.ajdt.core/testdata/src1/trace/ExecTrace.java b/org.aspectj.ajdt.core/testdata/src1/trace/ExecTrace.java new file mode 100644 index 000000000..c0ac25f34 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/trace/ExecTrace.java @@ -0,0 +1,7 @@ +package trace; + +public aspect ExecTrace extends MegaTrace { + pointcut where(): execution(public * *(..)); + + declare parents: * implements Marker; +}
\ No newline at end of file diff --git a/org.aspectj.ajdt.core/testdata/src1/trace/MegaTrace.java b/org.aspectj.ajdt.core/testdata/src1/trace/MegaTrace.java new file mode 100644 index 000000000..dff9a8f20 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/trace/MegaTrace.java @@ -0,0 +1,33 @@ +package trace; + +public abstract aspect MegaTrace { + abstract pointcut where(); + + Object around(): where() { + System.out.println("around enter: " + thisJoinPointStaticPart); + Object ret = proceed(); + System.out.println("around exit: " + thisJoinPointStaticPart); + return ret; + } + + before(): where() { + System.out.println("enter: " + thisJoinPointStaticPart); + } + + after(): where() { + System.out.println("exit: " + thisJoinPointStaticPart); + } + + + declare warning: where() && execution(void main(..)): + "tracing execution of main"; + + public interface Marker{} + private String Marker.name = "foo-bar"; + + public String sayHi() { return "hi"; } + + public static String getName(Marker m) { + return m.name; + } +}
\ No newline at end of file diff --git a/org.aspectj.ajdt.core/testdata/src1/tracep1/TraceTest.java b/org.aspectj.ajdt.core/testdata/src1/tracep1/TraceTest.java new file mode 100644 index 000000000..e639bd5a3 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/tracep1/TraceTest.java @@ -0,0 +1,11 @@ +package tracep1; + +public class TraceTest { + + public static void test() { + TraceTest t = new TraceTest(); + + System.out.println(trace.MegaTrace.getName(t)); + System.out.println(t.sayHi()); + } +}
\ No newline at end of file |