aboutsummaryrefslogtreecommitdiffstats
path: root/tests/features151
diff options
context:
space:
mode:
authoraclement <aclement>2006-01-19 09:40:04 +0000
committeraclement <aclement>2006-01-19 09:40:04 +0000
commit7e6cfb2bbb19a01ba9043a3e791d9128dd162e75 (patch)
tree08b891aad76177c7a22fa36fd2b28a60d90c04b8 /tests/features151
parent04067a6017182b42f520e450240dc90a2ed86bb4 (diff)
downloadaspectj-7e6cfb2bbb19a01ba9043a3e791d9128dd162e75.tar.gz
aspectj-7e6cfb2bbb19a01ba9043a3e791d9128dd162e75.zip
77166 - newarray joinpoint - testcode
Diffstat (limited to 'tests/features151')
-rw-r--r--tests/features151/newarrayjoinpoint/Eight.java11
-rw-r--r--tests/features151/newarrayjoinpoint/Eleven.java24
-rw-r--r--tests/features151/newarrayjoinpoint/Five.java17
-rw-r--r--tests/features151/newarrayjoinpoint/Four.java21
-rw-r--r--tests/features151/newarrayjoinpoint/Nine.java11
-rw-r--r--tests/features151/newarrayjoinpoint/One.java12
-rw-r--r--tests/features151/newarrayjoinpoint/Seven.java9
-rw-r--r--tests/features151/newarrayjoinpoint/Six.java10
-rw-r--r--tests/features151/newarrayjoinpoint/Ten.java25
-rw-r--r--tests/features151/newarrayjoinpoint/Three.java13
-rw-r--r--tests/features151/newarrayjoinpoint/Twelve.java25
-rw-r--r--tests/features151/newarrayjoinpoint/Two.java12
12 files changed, 190 insertions, 0 deletions
diff --git a/tests/features151/newarrayjoinpoint/Eight.java b/tests/features151/newarrayjoinpoint/Eight.java
new file mode 100644
index 000000000..7a93808d5
--- /dev/null
+++ b/tests/features151/newarrayjoinpoint/Eight.java
@@ -0,0 +1,11 @@
+public class Eight {
+ public static void main(String []argv) {
+ Integer[][] Is = new Integer[5][6];
+ int[][] is = new int[2][4];
+ }
+}
+
+aspect X {
+ before(): call(int[][].new(int,int)) { System.err.println("advice running 1");}
+ before(): call(Integer[][].new(int,int)) { System.err.println("advice running 2");}
+}
diff --git a/tests/features151/newarrayjoinpoint/Eleven.java b/tests/features151/newarrayjoinpoint/Eleven.java
new file mode 100644
index 000000000..da8964fdb
--- /dev/null
+++ b/tests/features151/newarrayjoinpoint/Eleven.java
@@ -0,0 +1,24 @@
+// let's look at using it for real...
+
+public class Eleven {
+
+ static int[] is1,is2;
+
+ public static void main(String []argv) {
+ is1 = new int[5];
+ is2 = new int[8];
+ }
+}
+
+aspect X {
+
+ Object interestingArray = null;
+
+ after(int size) returning(Object o): call(*.new(..)) && within(Eleven) && args(size) {
+ if (size==8) {
+ System.err.println("Found the interesting array");
+ interestingArray = o;
+ }
+ }
+
+} \ No newline at end of file
diff --git a/tests/features151/newarrayjoinpoint/Five.java b/tests/features151/newarrayjoinpoint/Five.java
new file mode 100644
index 000000000..c87e12248
--- /dev/null
+++ b/tests/features151/newarrayjoinpoint/Five.java
@@ -0,0 +1,17 @@
+// different advice kinds on the newarray jp
+public class Five {
+ public static void main(String []argv) {
+ Integer[] Is = new Integer[5];
+ }
+}
+
+aspect X {
+ before(): call(new(..)) && within(Five) { System.err.println("before");}
+}
+aspect Y {
+ after(): call(new(..)) && within(Five){System.err.println("after");}
+ after() returning: call(new(..)) && within(Five){System.err.println("after returning");}
+}
+aspect Z {
+ Integer[] around(): call(new(..)) && within(Five){System.err.println("around!"); return new Integer[500]; }
+}
diff --git a/tests/features151/newarrayjoinpoint/Four.java b/tests/features151/newarrayjoinpoint/Four.java
new file mode 100644
index 000000000..8381f0c42
--- /dev/null
+++ b/tests/features151/newarrayjoinpoint/Four.java
@@ -0,0 +1,21 @@
+// what about printing the join point?
+public class Four {
+ public static void main(String []argv) {
+ Integer[] Is = new Integer[5];
+ Foo f = new Foo(6);
+ }
+}
+
+aspect X {
+ before(): call(Integer[].new(int)) {
+ System.err.println("tjp1=>"+thisJoinPoint);
+ }
+ before(): call(Foo.new(int)) {
+ System.err.println("tjp2=>"+thisJoinPoint);
+ }
+}
+class Foo {
+ Foo(int i) {
+
+ }
+}
diff --git a/tests/features151/newarrayjoinpoint/Nine.java b/tests/features151/newarrayjoinpoint/Nine.java
new file mode 100644
index 000000000..0e9f5fde6
--- /dev/null
+++ b/tests/features151/newarrayjoinpoint/Nine.java
@@ -0,0 +1,11 @@
+public class Nine {
+ public static void main(String []argv) {
+ Integer[][] Is = new Integer[5][6];
+ int[][] is = new int[2][4];
+ }
+}
+
+aspect X {
+ before(int a,int b): call(int[][].new(int,int)) && args(a,b) { System.err.println("advice running 1 ("+a+","+b+")");}
+ before(int a,int b): call(Integer[][].new(int,int)) && args(a,b) { System.err.println("advice running 2 ("+a+","+b+")");}
+}
diff --git a/tests/features151/newarrayjoinpoint/One.java b/tests/features151/newarrayjoinpoint/One.java
new file mode 100644
index 000000000..965746cbb
--- /dev/null
+++ b/tests/features151/newarrayjoinpoint/One.java
@@ -0,0 +1,12 @@
+// basics
+public class One {
+ public static void main(String []argv) {
+ Integer[] is = new Integer[5];
+ }
+}
+
+aspect X {
+ before(): call(Integer[].new(..)) {
+ System.err.println("advice running");
+ }
+}
diff --git a/tests/features151/newarrayjoinpoint/Seven.java b/tests/features151/newarrayjoinpoint/Seven.java
new file mode 100644
index 000000000..da4bb7543
--- /dev/null
+++ b/tests/features151/newarrayjoinpoint/Seven.java
@@ -0,0 +1,9 @@
+public class Seven {
+ public static void main(String []argv) {
+ int[] is = new int[5];
+ }
+}
+
+aspect X {
+ before(): call(int[].new(int)) { System.err.println("advice running");}
+}
diff --git a/tests/features151/newarrayjoinpoint/Six.java b/tests/features151/newarrayjoinpoint/Six.java
new file mode 100644
index 000000000..1087d1c72
--- /dev/null
+++ b/tests/features151/newarrayjoinpoint/Six.java
@@ -0,0 +1,10 @@
+// accessing the size of the array
+public class Six {
+ public static void main(String []argv) {
+ Integer[] Is = new Integer[5];
+ }
+}
+
+aspect X {
+ before(int n): call(Integer[].new(int)) && args(n) { System.err.println("Array size = "+n);}
+} \ No newline at end of file
diff --git a/tests/features151/newarrayjoinpoint/Ten.java b/tests/features151/newarrayjoinpoint/Ten.java
new file mode 100644
index 000000000..b9313f04e
--- /dev/null
+++ b/tests/features151/newarrayjoinpoint/Ten.java
@@ -0,0 +1,25 @@
+public class Ten {
+
+ public static void main(String []argv) {
+ Ten a = new Ten();
+ int [] is = new int[5];
+ }
+}
+
+aspect X {
+
+ pointcut p(Object o): call(new(..)) && target(o) && within(Ten);
+
+ before(Object o): p(o) {
+ System.err.println("before "+o);
+ }
+
+ after(Object o): p(o) {
+ System.err.println("after "+o);
+ }
+
+ after() returning(Object o): call(*.new(..)) && within(Ten) {
+ System.err.println("afterReturning "+o.getClass());
+ }
+
+} \ No newline at end of file
diff --git a/tests/features151/newarrayjoinpoint/Three.java b/tests/features151/newarrayjoinpoint/Three.java
new file mode 100644
index 000000000..93c96b88c
--- /dev/null
+++ b/tests/features151/newarrayjoinpoint/Three.java
@@ -0,0 +1,13 @@
+// incorrect signature
+public class Three {
+ public static void main(String []argv) {
+ Integer[] Is = new Integer[5];
+ }
+}
+
+aspect X {
+ before(): execution(Integer.new(..)) { } // no match, it's execution
+ before(): call(Integer.new(..)) { } // no match, it's an integer array
+ before(): execution(Integer[].new(..)) { } // no match, no execution jp
+ before(): call(Integer[].new()) { } // no match, the call takes an int
+}
diff --git a/tests/features151/newarrayjoinpoint/Twelve.java b/tests/features151/newarrayjoinpoint/Twelve.java
new file mode 100644
index 000000000..f4f802db5
--- /dev/null
+++ b/tests/features151/newarrayjoinpoint/Twelve.java
@@ -0,0 +1,25 @@
+// writing general advice for multiple array types
+
+public class Twelve {
+
+ static int[] is1;
+ static Integer[] is2;
+ static String[][] strs;
+
+ public static void main(String []argv) {
+ is1 = new int[5];
+ is2 = new Integer[8];
+ strs = new String[4][8];
+ }
+}
+
+aspect X {
+
+ after() returning(Object o): call(*.new(..)) && within(Twelve) {
+ System.err.println("It is "+o.getClass());
+ System.err.println("Is it an array? "+o.getClass().isArray());
+ System.err.println("Component type is "+o.getClass().getComponentType());
+ System.err.println("--");
+ }
+
+} \ No newline at end of file
diff --git a/tests/features151/newarrayjoinpoint/Two.java b/tests/features151/newarrayjoinpoint/Two.java
new file mode 100644
index 000000000..008ece774
--- /dev/null
+++ b/tests/features151/newarrayjoinpoint/Two.java
@@ -0,0 +1,12 @@
+// Using wildcard for type
+public class Two {
+ public static void main(String []argv) {
+ Integer[] Is = new Integer[5];
+ }
+}
+
+aspect X {
+ before(): call(*.new(..)) {
+ System.err.println("advice running");
+ }
+}