]> source.dussan.org Git - aspectj.git/commitdiff
LTW and around inling test for code style
authoravasseur <avasseur>
Tue, 17 May 2005 08:59:54 +0000 (08:59 +0000)
committeravasseur <avasseur>
Tue, 17 May 2005 08:59:54 +0000 (08:59 +0000)
tests/java5/ataspectj/ajc-ant.xml
tests/java5/ataspectj/ataspectj/AroundInlineMungerTest2.aj [new file with mode: 0644]
tests/java5/ataspectj/ataspectj/AroundInlineMungerTestAspects2.aj [new file with mode: 0644]
tests/java5/ataspectj/ataspectj/aop-aroundinlinemungertest2.xml [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java
tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java
tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml
tests/src/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml

index d6034f2a77f5532d5906cf1364ee58c05a7a0e35..ab0e52437060085f65eb592b471fe76523f6c6e9 100644 (file)
         </java>
     </target>
 
+    <target name="ltw.AroundInlineMungerTest2">
+        <java fork="yes" classname="ataspectj.AroundInlineMungerTest2" failonerror="yes">
+            <classpath refid="aj.path"/>
+            <jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
+            <jvmarg value="-Daj5.def=ataspectj/aop-aroundinlinemungertest2.xml"/>
+        </java>
+    </target>
+
     <target name="javac.ltw" depends="compile:javac, ltw"/>
 </project>
\ No newline at end of file
diff --git a/tests/java5/ataspectj/ataspectj/AroundInlineMungerTest2.aj b/tests/java5/ataspectj/ataspectj/AroundInlineMungerTest2.aj
new file mode 100644 (file)
index 0000000..eeec49f
--- /dev/null
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ * 
+ * Contributors:
+ *   Alexandre Vasseur         initial implementation
+ *******************************************************************************/
+package ataspectj;
+
+import junit.framework.TestCase;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.ProceedingJoinPoint;
+
+/**
+ * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
+ */
+public class AroundInlineMungerTest2 extends TestCase {
+
+    public static void main(String[] args) {
+        TestHelper.runAndThrowOnFailure(suite());
+    }
+
+    public static junit.framework.Test suite() {
+        return new junit.framework.TestSuite(AroundInlineMungerTest2.class);
+    }
+
+    public void testAccessNonPublicFromAroundAdvice() {
+        target();
+        assertEquals(3, AroundInlineMungerTestAspects2.Open.aroundCount);
+        assertEquals(6, AroundInlineMungerTestAspects2.Open.beforeCount);
+    }
+
+    public void target() {}
+
+}
diff --git a/tests/java5/ataspectj/ataspectj/AroundInlineMungerTestAspects2.aj b/tests/java5/ataspectj/ataspectj/AroundInlineMungerTestAspects2.aj
new file mode 100644 (file)
index 0000000..28d7f05
--- /dev/null
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ * 
+ * Contributors:
+ *   Alexandre Vasseur         initial implementation
+ *******************************************************************************/
+package ataspectj;
+
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.ProceedingJoinPoint;
+
+/**
+ * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
+ */
+public class AroundInlineMungerTestAspects2 {
+
+    public static abstract aspect OpenBase {
+        protected void superMethod() {}
+    }
+
+    public static abstract aspect OpenSubBase extends OpenBase {}
+
+    // aspect will be prepared for inlining
+    public static aspect Open extends OpenSubBase {
+
+        public static int aroundCount = 0;
+        public static int beforeCount = 0;
+
+        private int i;
+        private static int I;
+
+        Object around() : execution(* ataspectj.AroundInlineMungerTest2.target()) {
+            aroundCount++;
+            priv(1, 2L, 3);
+            super.superMethod();
+            new Inner().priv();//fails to be wrapped so this advice will not be inlined but previous call were still prepared
+            return proceed();
+        }
+
+        // this advice to test around advice body call/get/set advising
+        before() : (call(* ataspectj.AroundInlineMungerTestAspects2.Open.priv(..))
+                  || get(int ataspectj.AroundInlineMungerTestAspects2.Open.i)
+                  || set(int ataspectj.AroundInlineMungerTestAspects2.Open.i)
+                  || get(int ataspectj.AroundInlineMungerTestAspects2.Open.I)
+                  || set(int ataspectj.AroundInlineMungerTestAspects2.Open.I)
+                 )&& this(ataspectj.AroundInlineMungerTestAspects2.Open) {
+            beforeCount++;
+        }
+
+        Object around() : execution(* ataspectj.AroundInlineMungerTest2.target()) {
+            aroundCount++;
+            super.superMethod();
+            new Inner().priv();//fails to be wrapped so next calls won't be prepared but previous was
+            priv(1, 2L, 3);
+            return proceed();
+        }
+
+        Object around() : execution(* ataspectj.AroundInlineMungerTest2.target()) {
+            aroundCount++;
+            // all those field access will be wrapped
+            int li = i;
+            i = li;
+            int lI = I;
+            I = lI;
+            return proceed();
+        }
+
+        // -- some private member for which access will be wrapped so that around advice can be inlined
+
+        private void priv(int i, long j, int k) {
+            long l = i + j + k;
+        }
+
+        private static class Inner {
+            private Inner() {}
+            private void priv() {};
+        }
+    }
+
+}
diff --git a/tests/java5/ataspectj/ataspectj/aop-aroundinlinemungertest2.xml b/tests/java5/ataspectj/ataspectj/aop-aroundinlinemungertest2.xml
new file mode 100644 (file)
index 0000000..3f7de3c
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<aspectj>
+    <weaver options="-XmessageHolderClass:ataspectj.TestHelper"/>
+    <aspects>
+        <aspect name="ataspectj.AroundInlineMungerTestAspects2.Open"/>
+    </aspects>
+</aspectj>
index 214d0cb965a30daa3a37774a99c98422ecf28945..d2bc160e0daf44f5fc1aecf9a2d6e3e293e580df 100644 (file)
@@ -63,5 +63,8 @@ public class AtAjLTWTests extends XMLBasedAjcTestCase {
         runTest("AjcLTW AroundInlineMungerTest -XnoInline -Xreweavable");
     }
 
+    public void testAjcLTWAroundInlineMungerTest2() {
+        runTest("AjcLTW AroundInlineMungerTest2");
+    }
 
 }
index 7e0921f40a9cbffc50d97ce0672d0bdfabc8c60d..264c4693098724232542906b4a385d9cacbc2833 100644 (file)
@@ -84,4 +84,7 @@ public class AtAjSyntaxTests extends XMLBasedAjcTestCase {
         runTest("AroundInlineMunger");
     }
 
+    public void testAroundInlineMunger2() {
+        runTest("AroundInlineMunger2");
+    }
 }
\ No newline at end of file
index 1f430a8617e6f324d922cf600de9a624d88ee9bc..5a770808afec23599448ab5f2e7831d5d3b9ec83 100644 (file)
         <ant file="ajc-ant.xml" target="ltw.AroundInlineMungerTest" verbose="true"/>
     </ajc-test>
 
+    <ajc-test dir="java5/ataspectj" title="AjcLTW AroundInlineMungerTest2">
+        <compile
+            files="ataspectj/AroundInlineMungerTestAspects2.aj"
+            options="-1.5 -Xlint:ignore"/>
+        <compile
+            files="ataspectj/AroundInlineMungerTest2.aj,ataspectj/TestHelper.java"
+            options="-1.5 -Xreweavable"/>
+        <ant file="ajc-ant.xml" target="ltw.AroundInlineMungerTest2" verbose="true"/>
+    </ajc-test>
 </suite>
\ No newline at end of file
index 594f736deb4e63226a37fc73455fbe505c621d8c..055567d30f3dfd3f842b3176f46790b32e408882 100644 (file)
@@ -95,4 +95,9 @@
         <compile files="ataspectj/AroundInlineMungerTest.java,ataspectj/AroundInlineMungerTestAspects.java,ataspectj/TestHelper.java" options="-1.5 -Xdev:NoAtAspectJProcessing -Xlint:ignore"/>
         <run class="ataspectj.AroundInlineMungerTest"/>
     </ajc-test>
+
+    <ajc-test dir="java5/ataspectj" title="AroundInlineMunger2">
+        <compile files="ataspectj/AroundInlineMungerTest2.aj,ataspectj/AroundInlineMungerTestAspects2.aj,ataspectj/TestHelper.java" options="-1.5 -Xlint:ignore"/>
+        <run class="ataspectj.AroundInlineMungerTest2"/>
+    </ajc-test>
 </suite>
\ No newline at end of file