diff options
author | aclement <aclement> | 2004-02-24 13:43:56 +0000 |
---|---|---|
committer | aclement <aclement> | 2004-02-24 13:43:56 +0000 |
commit | 16a0abd70e5fe2538c32994de05f52b6bf939ef5 (patch) | |
tree | 3a8ca19141c2a3f15663c4f721b2397529af1e43 /ajde/testdata | |
parent | 36f8e3c561a721243f8e9e6c0cfb71547249e300 (diff) | |
download | aspectj-16a0abd70e5fe2538c32994de05f52b6bf939ef5.tar.gz aspectj-16a0abd70e5fe2538c32994de05f52b6bf939ef5.zip |
Fix for Bug 36430: Xreweavable support
Diffstat (limited to 'ajde/testdata')
-rw-r--r-- | ajde/testdata/ReweavableTest/CalculatePI.java | 26 | ||||
-rw-r--r-- | ajde/testdata/ReweavableTest/Logger.aj | 11 | ||||
-rw-r--r-- | ajde/testdata/ReweavableTest/NonReweavable1.lst | 4 | ||||
-rw-r--r-- | ajde/testdata/ReweavableTest/Reweavable1.lst | 5 | ||||
-rw-r--r-- | ajde/testdata/ReweavableTest/Reweavable2.lst | 4 | ||||
-rw-r--r-- | ajde/testdata/ReweavableTest/ReweavableCompress1.lst | 5 | ||||
-rw-r--r-- | ajde/testdata/ReweavableTest/Second.lst | 3 | ||||
-rw-r--r-- | ajde/testdata/ReweavableTest/SecondAspect.aj | 5 | ||||
-rw-r--r-- | ajde/testdata/ReweavableTest/TJP1.lst | 5 | ||||
-rw-r--r-- | ajde/testdata/ReweavableTest/TJP2.lst | 3 | ||||
-rw-r--r-- | ajde/testdata/ReweavableTest/ThirdAspect.aj | 5 | ||||
-rw-r--r-- | ajde/testdata/ReweavableTest/tjp/Demo.java | 38 | ||||
-rw-r--r-- | ajde/testdata/ReweavableTest/tjp/GetInfo.java | 50 |
13 files changed, 164 insertions, 0 deletions
diff --git a/ajde/testdata/ReweavableTest/CalculatePI.java b/ajde/testdata/ReweavableTest/CalculatePI.java new file mode 100644 index 000000000..84ae08583 --- /dev/null +++ b/ajde/testdata/ReweavableTest/CalculatePI.java @@ -0,0 +1,26 @@ +import java.util.Random; + +public class CalculatePI { + + static Random r = new Random(); + static double piApproximation = 1.0f; + static int repetitions = 500000; + static int iteration = 0; + static double inSquare = 0; + static double inCircle = 0; + + public static void main(String[] args) { + for (iteration = 0;iteration<repetitions;iteration++) approximate(); + piApproximation = (inCircle/inSquare)*4.0f; + System.out.println("After "+repetitions+" iterations, pi is estimated to be "+piApproximation); + } + + public static void approximate() { + double x = r.nextDouble(); + double y = r.nextDouble(); + inSquare++; + if (x*x + y*y < 1) {inCircle++;} + } + + +}
\ No newline at end of file diff --git a/ajde/testdata/ReweavableTest/Logger.aj b/ajde/testdata/ReweavableTest/Logger.aj new file mode 100644 index 000000000..b41c8842f --- /dev/null +++ b/ajde/testdata/ReweavableTest/Logger.aj @@ -0,0 +1,11 @@ +
+
+public aspect Logger {
+
+ after(): call(* approximate(..)) {
+ if (CalculatePI.iteration%10000==0)
+ System.out.println("Approximation is now:"+
+ (CalculatePI.inCircle/CalculatePI.inSquare)*4.0f);
+ }
+
+}
\ No newline at end of file diff --git a/ajde/testdata/ReweavableTest/NonReweavable1.lst b/ajde/testdata/ReweavableTest/NonReweavable1.lst new file mode 100644 index 000000000..c40df5e4c --- /dev/null +++ b/ajde/testdata/ReweavableTest/NonReweavable1.lst @@ -0,0 +1,4 @@ +CalculatePI.java
+Logger.aj
+-verbose
+-noExit
\ No newline at end of file diff --git a/ajde/testdata/ReweavableTest/Reweavable1.lst b/ajde/testdata/ReweavableTest/Reweavable1.lst new file mode 100644 index 000000000..43c6b246f --- /dev/null +++ b/ajde/testdata/ReweavableTest/Reweavable1.lst @@ -0,0 +1,5 @@ +CalculatePI.java
+Logger.aj
+-Xreweavable
+-verbose
+-noExit
\ No newline at end of file diff --git a/ajde/testdata/ReweavableTest/Reweavable2.lst b/ajde/testdata/ReweavableTest/Reweavable2.lst new file mode 100644 index 000000000..6f0b9d728 --- /dev/null +++ b/ajde/testdata/ReweavableTest/Reweavable2.lst @@ -0,0 +1,4 @@ +SecondAspect.aj
+-Xreweavable
+-verbose
+-noExit
\ No newline at end of file diff --git a/ajde/testdata/ReweavableTest/ReweavableCompress1.lst b/ajde/testdata/ReweavableTest/ReweavableCompress1.lst new file mode 100644 index 000000000..af8fc60eb --- /dev/null +++ b/ajde/testdata/ReweavableTest/ReweavableCompress1.lst @@ -0,0 +1,5 @@ +CalculatePI.java
+Logger.aj
+-Xreweavable:compress
+-verbose
+-noExit
\ No newline at end of file diff --git a/ajde/testdata/ReweavableTest/Second.lst b/ajde/testdata/ReweavableTest/Second.lst new file mode 100644 index 000000000..9a3344121 --- /dev/null +++ b/ajde/testdata/ReweavableTest/Second.lst @@ -0,0 +1,3 @@ +Logger.aj
+-Xreweavable
+-verbose
\ No newline at end of file diff --git a/ajde/testdata/ReweavableTest/SecondAspect.aj b/ajde/testdata/ReweavableTest/SecondAspect.aj new file mode 100644 index 000000000..413f4969e --- /dev/null +++ b/ajde/testdata/ReweavableTest/SecondAspect.aj @@ -0,0 +1,5 @@ +
+public aspect SecondAspect {
+
+ declare parents: Logger implements java.io.Serializable;
+}
\ No newline at end of file diff --git a/ajde/testdata/ReweavableTest/TJP1.lst b/ajde/testdata/ReweavableTest/TJP1.lst new file mode 100644 index 000000000..f686a5e88 --- /dev/null +++ b/ajde/testdata/ReweavableTest/TJP1.lst @@ -0,0 +1,5 @@ +tjp/Demo.java
+tjp/GetInfo.java
+-Xreweavable
+-verbose
+-noExit
\ No newline at end of file diff --git a/ajde/testdata/ReweavableTest/TJP2.lst b/ajde/testdata/ReweavableTest/TJP2.lst new file mode 100644 index 000000000..27e22167e --- /dev/null +++ b/ajde/testdata/ReweavableTest/TJP2.lst @@ -0,0 +1,3 @@ +-Xreweavable
+-verbose
+-noExit
\ No newline at end of file diff --git a/ajde/testdata/ReweavableTest/ThirdAspect.aj b/ajde/testdata/ReweavableTest/ThirdAspect.aj new file mode 100644 index 000000000..c6c6b1a43 --- /dev/null +++ b/ajde/testdata/ReweavableTest/ThirdAspect.aj @@ -0,0 +1,5 @@ +
+public aspect ThirdAspect {
+
+ int CalculatePI.x;
+}
\ No newline at end of file diff --git a/ajde/testdata/ReweavableTest/tjp/Demo.java b/ajde/testdata/ReweavableTest/tjp/Demo.java new file mode 100644 index 000000000..c4a4f057c --- /dev/null +++ b/ajde/testdata/ReweavableTest/tjp/Demo.java @@ -0,0 +1,38 @@ + +/* + +Copyright (c) Xerox Corporation 1998-2002. All rights reserved. + +Use and copying of this software and preparation of derivative works based +upon this software are permitted. Any distribution of this software or +derivative works must comply with all applicable United States export control +laws. + +This software is made available AS IS, and Xerox Corporation makes no warranty +about the software, its performance or its conformity to any specification. + +*/ +package tjp; + +public class Demo { + static Demo d; + + public static void main(String[] args){ + new Demo().go(); + } + + void go(){ + d = new Demo(); + d.foo(1,d); + System.out.println(d.bar(new Integer(3))); + } + + void foo(int i, Object o){ + System.out.println("Demo.foo(" + i + ", " + o + ")\n"); + } + + String bar (Integer j){ + System.out.println("Demo.bar(" + j + ")\n"); + return "Demo.bar(" + j + ")"; + } +} diff --git a/ajde/testdata/ReweavableTest/tjp/GetInfo.java b/ajde/testdata/ReweavableTest/tjp/GetInfo.java new file mode 100644 index 000000000..458acb56f --- /dev/null +++ b/ajde/testdata/ReweavableTest/tjp/GetInfo.java @@ -0,0 +1,50 @@ + +/* +Copyright (c) Xerox Corporation 1998-2002. All rights reserved. + +Use and copying of this software and preparation of derivative works based +upon this software are permitted. Any distribution of this software or +derivative works must comply with all applicable United States export control +laws. + +This software is made available AS IS, and Xerox Corporation makes no warranty +about the software, its performance or its conformity to any specification. +*/ + +package tjp; + +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.reflect.CodeSignature; + +aspect GetInfo { + + static final void println(String s){ System.out.println(s); } + + pointcut goCut(): cflow(this(Demo) && execution(void go())); + + pointcut demoExecs(): within(Demo) && execution(* *(..)); + + Object around(): demoExecs() && !execution(* go()) && goCut() { + println("Intercepted message: " + + thisJoinPointStaticPart.getSignature().getName()); + println("in class: " + + thisJoinPointStaticPart.getSignature().getDeclaringType().getName()); + printParameters(thisJoinPoint); + println("Running original method: \n" ); + Object result = proceed(); + println(" result: " + result ); + return result; + } + + static private void printParameters(JoinPoint jp) { + println("Arguments: " ); + Object[] args = jp.getArgs(); + String[] names = ((CodeSignature)jp.getSignature()).getParameterNames(); + Class[] types = ((CodeSignature)jp.getSignature()).getParameterTypes(); + for (int i = 0; i < args.length; i++) { + println(" " + i + ". " + names[i] + + " : " + types[i].getName() + + " = " + args[i]); + } + } +} |