diff options
author | aclement <aclement> | 2007-01-11 16:04:29 +0000 |
---|---|---|
committer | aclement <aclement> | 2007-01-11 16:04:29 +0000 |
commit | cfd711b9628154e0b2eb2df174124699cf831f83 (patch) | |
tree | 83b9afa0e996777cf4cdcdff23f3b69f72df031b /ajde.core/testdata/ReweavableTest | |
parent | 41fefd58f8b716468b2bdba2335eb921e5eb3a7b (diff) | |
download | aspectj-cfd711b9628154e0b2eb2df174124699cf831f83.tar.gz aspectj-cfd711b9628154e0b2eb2df174124699cf831f83.zip |
new ajde.core module
Diffstat (limited to 'ajde.core/testdata/ReweavableTest')
-rw-r--r-- | ajde.core/testdata/ReweavableTest/CalculatePI.java | 26 | ||||
-rw-r--r-- | ajde.core/testdata/ReweavableTest/Logger.aj | 11 | ||||
-rw-r--r-- | ajde.core/testdata/ReweavableTest/NonReweavable1.lst | 5 | ||||
-rw-r--r-- | ajde.core/testdata/ReweavableTest/Reweavable1.lst | 4 | ||||
-rw-r--r-- | ajde.core/testdata/ReweavableTest/Reweavable2.lst | 3 | ||||
-rw-r--r-- | ajde.core/testdata/ReweavableTest/ReweavableCompress1.lst | 5 | ||||
-rw-r--r-- | ajde.core/testdata/ReweavableTest/Second.lst | 2 | ||||
-rw-r--r-- | ajde.core/testdata/ReweavableTest/SecondAspect.aj | 5 | ||||
-rw-r--r-- | ajde.core/testdata/ReweavableTest/TJP1.lst | 4 | ||||
-rw-r--r-- | ajde.core/testdata/ReweavableTest/TJP2.lst | 2 | ||||
-rw-r--r-- | ajde.core/testdata/ReweavableTest/ThirdAspect.aj | 5 | ||||
-rw-r--r-- | ajde.core/testdata/ReweavableTest/tjp/Demo.java | 38 | ||||
-rw-r--r-- | ajde.core/testdata/ReweavableTest/tjp/GetInfo.java | 50 |
13 files changed, 160 insertions, 0 deletions
diff --git a/ajde.core/testdata/ReweavableTest/CalculatePI.java b/ajde.core/testdata/ReweavableTest/CalculatePI.java new file mode 100644 index 000000000..84ae08583 --- /dev/null +++ b/ajde.core/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.core/testdata/ReweavableTest/Logger.aj b/ajde.core/testdata/ReweavableTest/Logger.aj new file mode 100644 index 000000000..3ce6035a2 --- /dev/null +++ b/ajde.core/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.core/testdata/ReweavableTest/NonReweavable1.lst b/ajde.core/testdata/ReweavableTest/NonReweavable1.lst new file mode 100644 index 000000000..4de179199 --- /dev/null +++ b/ajde.core/testdata/ReweavableTest/NonReweavable1.lst @@ -0,0 +1,5 @@ +CalculatePI.java +Logger.aj +-verbose +-noExit +-XnotReweavable
\ No newline at end of file diff --git a/ajde.core/testdata/ReweavableTest/Reweavable1.lst b/ajde.core/testdata/ReweavableTest/Reweavable1.lst new file mode 100644 index 000000000..e51de8c5c --- /dev/null +++ b/ajde.core/testdata/ReweavableTest/Reweavable1.lst @@ -0,0 +1,4 @@ +CalculatePI.java +Logger.aj +-verbose +-noExit
\ No newline at end of file diff --git a/ajde.core/testdata/ReweavableTest/Reweavable2.lst b/ajde.core/testdata/ReweavableTest/Reweavable2.lst new file mode 100644 index 000000000..25058c806 --- /dev/null +++ b/ajde.core/testdata/ReweavableTest/Reweavable2.lst @@ -0,0 +1,3 @@ +SecondAspect.aj +-verbose +-noExit
\ No newline at end of file diff --git a/ajde.core/testdata/ReweavableTest/ReweavableCompress1.lst b/ajde.core/testdata/ReweavableTest/ReweavableCompress1.lst new file mode 100644 index 000000000..a120df8e1 --- /dev/null +++ b/ajde.core/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.core/testdata/ReweavableTest/Second.lst b/ajde.core/testdata/ReweavableTest/Second.lst new file mode 100644 index 000000000..5b89c9189 --- /dev/null +++ b/ajde.core/testdata/ReweavableTest/Second.lst @@ -0,0 +1,2 @@ +Logger.aj +-verbose
\ No newline at end of file diff --git a/ajde.core/testdata/ReweavableTest/SecondAspect.aj b/ajde.core/testdata/ReweavableTest/SecondAspect.aj new file mode 100644 index 000000000..6c3bcbcac --- /dev/null +++ b/ajde.core/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.core/testdata/ReweavableTest/TJP1.lst b/ajde.core/testdata/ReweavableTest/TJP1.lst new file mode 100644 index 000000000..ecde6a091 --- /dev/null +++ b/ajde.core/testdata/ReweavableTest/TJP1.lst @@ -0,0 +1,4 @@ +tjp/Demo.java +tjp/GetInfo.java +-verbose +-noExit
\ No newline at end of file diff --git a/ajde.core/testdata/ReweavableTest/TJP2.lst b/ajde.core/testdata/ReweavableTest/TJP2.lst new file mode 100644 index 000000000..f0ee74d56 --- /dev/null +++ b/ajde.core/testdata/ReweavableTest/TJP2.lst @@ -0,0 +1,2 @@ +-verbose +-noExit
\ No newline at end of file diff --git a/ajde.core/testdata/ReweavableTest/ThirdAspect.aj b/ajde.core/testdata/ReweavableTest/ThirdAspect.aj new file mode 100644 index 000000000..9e65cf66c --- /dev/null +++ b/ajde.core/testdata/ReweavableTest/ThirdAspect.aj @@ -0,0 +1,5 @@ + +public aspect ThirdAspect { + + int CalculatePI.x; +}
\ No newline at end of file diff --git a/ajde.core/testdata/ReweavableTest/tjp/Demo.java b/ajde.core/testdata/ReweavableTest/tjp/Demo.java new file mode 100644 index 000000000..c4a4f057c --- /dev/null +++ b/ajde.core/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.core/testdata/ReweavableTest/tjp/GetInfo.java b/ajde.core/testdata/ReweavableTest/tjp/GetInfo.java new file mode 100644 index 000000000..458acb56f --- /dev/null +++ b/ajde.core/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]); + } + } +} |