]> source.dussan.org Git - aspectj.git/commitdiff
Fix 449401: thisAspectInstance compile problem with -1.8
authorAndy Clement <aclement@gopivotal.com>
Thu, 30 Oct 2014 21:33:12 +0000 (14:33 -0700)
committerAndy Clement <aclement@gopivotal.com>
Thu, 30 Oct 2014 21:33:12 +0000 (14:33 -0700)
build/usedForMavenUpload/aspectjrt.pom
build/usedForMavenUpload/aspectjtools.pom
build/usedForMavenUpload/aspectjweaver.pom
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java
tests/src/org/aspectj/systemtest/AllTests18.java
tests/src/org/aspectj/systemtest/ajc184/Ajc184Tests.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc184/AllTestsAspectJ184.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc184/ajc184.xml [new file with mode: 0644]

index b8c2b93442c9ee9dd4e95552bec55f44fc11bba6..25c6146d75af0b4c29a99ebe88a6bab9091ec117 100644 (file)
@@ -5,7 +5,7 @@
   <groupId>org.aspectj</groupId>
   <artifactId>aspectjrt</artifactId>
   <packaging>jar</packaging>
-  <version>1.8.3.BUILD-SNAPSHOT</version>
+  <version>1.8.4.BUILD-SNAPSHOT</version>
   <name>AspectJ runtime</name>
   <description>The runtime needed to execute a program using AspectJ</description>
   <url>http://www.aspectj.org</url>
index 9febb62654030d08204ff8ec16e2bb81b2d2f170..defa88acf07ee28a54a844d32a6bdad8f5e4bfe1 100644 (file)
@@ -5,7 +5,7 @@
   <groupId>org.aspectj</groupId>
   <artifactId>aspectjtools</artifactId>
   <packaging>jar</packaging>
-  <version>1.8.3.BUILD-SNAPSHOT</version>
+  <version>1.8.4.BUILD-SNAPSHOT</version>
   <name>AspectJ tools</name>
   <description>Tools from the AspectJ project</description>
   <url>http://www.aspectj.org</url>
index 314de80630e91802315d30fab2ccece80b6fc4bf..ad82e409327ea22ae006df43c401c4691acf10f1 100644 (file)
@@ -5,7 +5,7 @@
   <groupId>org.aspectj</groupId>
   <artifactId>aspectjweaver</artifactId>
   <packaging>jar</packaging>
-  <version>1.8.3.BUILD-SNAPSHOT</version>
+  <version>1.8.4.BUILD-SNAPSHOT</version>
   <name>AspectJ weaver</name>
   <description>The AspectJ weaver introduces advices to java classes</description>
   <url>http://www.aspectj.org</url>
index f9b26b59a59cc485faccd3706e590d07495126ae..88556fccfdba1dc9fb0b96c032b39855472af1a2 100644 (file)
@@ -513,10 +513,12 @@ public class AjProblemReporter extends ProblemReporter {
        private final static char[] thisJoinPointName = "thisJoinPoint".toCharArray();
        private final static char[] thisJoinPointStaticPartName = "thisJoinPointStaticPart".toCharArray();
        private final static char[] thisEnclosingJoinPointStaticPartName = "thisEnclosingJoinPointStaticPart".toCharArray();
+       private final static char[] thisAspectInstanceName = "thisAspectInstance".toCharArray();
        
        public void uninitializedLocalVariable(LocalVariableBinding binding, ASTNode location) {
                if (CharOperation.equals(binding.name, thisJoinPointName) ||
                        CharOperation.equals(binding.name, thisJoinPointStaticPartName) ||
+                       CharOperation.equals(binding.name, thisAspectInstanceName) || 
                        CharOperation.equals(binding.name, thisEnclosingJoinPointStaticPartName)) {
                        // If in advice, this is not a problem
                        if (binding.declaringScope!=null && (binding.declaringScope.referenceContext() instanceof AdviceDeclaration ||
index 547a1781794c6a41e9c2cd21e9d156e942322c0e..aecbe05ab79fc5904652c0250f8763cae98eff52 100644 (file)
@@ -17,12 +17,14 @@ import org.aspectj.systemtest.ajc180.AllTestsAspectJ180;
 import org.aspectj.systemtest.ajc181.AllTestsAspectJ181;
 import org.aspectj.systemtest.ajc182.AllTestsAspectJ182; 
 import org.aspectj.systemtest.ajc183.AllTestsAspectJ183;
+import org.aspectj.systemtest.ajc184.AllTestsAspectJ184;
 
 public class AllTests18 {
 
        public static Test suite() {
                TestSuite suite = new TestSuite("AspectJ System Test Suite - 1.8");
                // $JUnit-BEGIN$ 
+               suite.addTest(AllTestsAspectJ184.suite()); 
                suite.addTest(AllTestsAspectJ183.suite()); 
                suite.addTest(AllTestsAspectJ182.suite()); 
                suite.addTest(AllTestsAspectJ181.suite()); 
diff --git a/tests/src/org/aspectj/systemtest/ajc184/Ajc184Tests.java b/tests/src/org/aspectj/systemtest/ajc184/Ajc184Tests.java
new file mode 100644 (file)
index 0000000..7ba5654
--- /dev/null
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Andy Clement - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc184;
+
+import java.io.File;
+
+import junit.framework.Test;
+
+import org.aspectj.testing.XMLBasedAjcTestCase;
+
+/**
+ * @author Andy Clement
+ */
+public class Ajc184Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
+
+       // The thisAspectInstance tests here are a copy from Ajc1612Tests but we are compiling with -1.8 and not -1.5
+       
+       public void testThisAspectInstance_239649_1() throws Exception {
+               // simple case
+               runTest("thisAspectInstance - 1");
+       }
+
+       public void testThisAspectInstance_239649_2() throws Exception {
+               // before advice toggling on/off through if called method
+               runTest("thisAspectInstance - 2");
+       }
+
+       public void testThisAspectInstance_239649_3() throws Exception {
+               // after advice toggling on/off through if called method
+               runTest("thisAspectInstance - 3");
+       }
+
+       public void testThisAspectInstance_239649_4() throws Exception {
+               // before advice, also using thisJoinPointStaticPart
+               runTest("thisAspectInstance - 4");
+       }
+
+       public void testThisAspectInstance_239649_5() throws Exception {
+               // before advice, also using thisJoinPoint
+               runTest("thisAspectInstance - 5");
+       }
+
+       public void testThisAspectInstance_239649_6() throws Exception {
+               // before advice, also using thisEnclosingJoinPointStaticPart
+               runTest("thisAspectInstance - 6");
+       }
+
+       public void testThisAspectInstance_239649_7() throws Exception {
+               // before advice, also using thisJoinPoint and thisJoinPointStaticPart
+               runTest("thisAspectInstance - 7");
+       }
+
+       public void testThisAspectInstance_239649_8() throws Exception {
+               // before advice, also using abstract aspects
+               runTest("thisAspectInstance - 8");
+       }
+
+       public void testThisAspectInstance_239649_9() throws Exception {
+               // before advice, also using abstract aspects 2
+               runTest("thisAspectInstance - 9");
+       }
+
+       public void testThisAspectInstance_239649_10() throws Exception {
+               // aspects in a package
+               runTest("thisAspectInstance - 10");
+       }
+
+       public void testThisAspectInstance_239649_11() throws Exception {
+               // non-singleton aspect - should be an error for now
+               runTest("thisAspectInstance - 11");
+       }
+
+       public void testThisAspectInstance_239649_12() throws Exception {
+               // arg binding and tjpsp
+               runTest("thisAspectInstance - 12");
+       }
+
+       public void testThisAspectInstance_239649_13() throws Exception {
+               // pass instance
+               runTest("thisAspectInstance - 13");
+       }
+
+       public void testThisAspectInstance_239649_14() throws Exception {
+               // multiple ifs
+               runTest("thisAspectInstance - 14");
+       }
+
+       public void testThisAspectInstance_239649_15() throws Exception {
+               // abstract aspects
+               runTest("thisAspectInstance - 15");
+       }
+       // ---
+
+       public static Test suite() {
+               return XMLBasedAjcTestCase.loadSuite(Ajc184Tests.class);
+       }
+
+       @Override
+       protected File getSpecFile() {
+        return getClassResource("ajc184.xml");
+       }
+
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc184/AllTestsAspectJ184.java b/tests/src/org/aspectj/systemtest/ajc184/AllTestsAspectJ184.java
new file mode 100644 (file)
index 0000000..1c1c61a
--- /dev/null
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Andy Clement - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc184;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.aspectj.systemtest.apt.AptTests;
+
+public class AllTestsAspectJ184 {
+
+       public static Test suite() {
+               TestSuite suite = new TestSuite("AspectJ 1.8.4 tests");
+               // $JUnit-BEGIN$
+               suite.addTest(Ajc184Tests.suite());
+               suite.addTest(AptTests.suite());
+               // $JUnit-END$
+               return suite;
+       }
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc184/ajc184.xml b/tests/src/org/aspectj/systemtest/ajc184/ajc184.xml
new file mode 100644 (file)
index 0000000..01d4d23
--- /dev/null
@@ -0,0 +1,180 @@
+<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
+
+<suite>
+
+
+<ajc-test dir="bugs1612/pr239649" title="thisAspectInstance - 1">
+<compile files="One.java" options="-1.8"/>
+<run class="One">
+  <stdout>
+  <line text="In instance check method doit()"/>
+  <line text="In advice()"/>
+  <line text="Method m() running"/>
+  </stdout>
+</run>
+</ajc-test>
+
+<ajc-test dir="bugs1612/pr239649" title="thisAspectInstance - 2">
+<compile files="Two.java" options="-1.8"/>
+<run class="Two">
+  <stdout>
+  <line text="In instance check method, count=1 so doit returns false"/>
+  <line text="Method m() running"/>
+  <line text="In instance check method, count=2 so doit returns true"/>
+  <line text="In advice()"/>
+  <line text="Method m() running"/>
+  <line text="In instance check method, count=3 so doit returns false"/>
+  <line text="Method m() running"/>
+  <line text="In instance check method, count=4 so doit returns true"/>
+  <line text="In advice()"/>
+  <line text="Method m() running"/>
+  </stdout>
+</run>
+</ajc-test>
+
+<ajc-test dir="bugs1612/pr239649" title="thisAspectInstance - 3">
+<compile files="Three.java" options="-1.8"/>
+<run class="Three">
+  <stdout>
+  <line text="Method m() running"/>
+  <line text="In instance check method, count=1 so doit returns false"/>
+  <line text="Method m() running"/>
+  <line text="In instance check method, count=2 so doit returns true"/>
+  <line text="In advice()"/>
+  <line text="Method m() running"/>
+  <line text="In instance check method, count=3 so doit returns false"/>
+  <line text="Method m() running"/>
+  <line text="In instance check method, count=4 so doit returns true"/>
+  <line text="In advice()"/>
+  </stdout>
+</run>
+</ajc-test>
+
+<ajc-test dir="bugs1612/pr239649" title="thisAspectInstance - 4">
+<compile files="Four.java" options="-1.8"/>
+<run class="Four">
+  <stdout>
+  <line text="In instance check method doit()"/>
+  <line text="In advice() execution(void Four.m())"/>
+  <line text="Method m() running"/>
+  </stdout>
+</run>
+</ajc-test>
+
+<ajc-test dir="bugs1612/pr239649" title="thisAspectInstance - 5">
+<compile files="Five.java" options="-1.8"/>
+<run class="Five">
+  <stdout>
+  <line text="In instance check method doit()"/>
+  <line text="In advice() arg0=abc"/>
+  <line text="Method m() running"/>
+  </stdout>
+</run>
+</ajc-test>
+
+<ajc-test dir="bugs1612/pr239649" title="thisAspectInstance - 6">
+<compile files="Six.java" options="-1.8"/>
+<run class="Six">
+  <stdout>
+  <line text="In instance check method doit()"/>
+  <line text="In advice() execution(void Six.main(String[]))"/>
+  <line text="Method m() running"/>
+  </stdout>
+</run>
+</ajc-test>
+
+<ajc-test dir="bugs1612/pr239649" title="thisAspectInstance - 7">
+<compile files="Seven.java" options="-1.8"/>
+<run class="Seven">
+  <stdout>
+  <line text="In instance check method doit()"/>
+  <line text="In advice() call(void Seven.m()) execution(void Seven.main(String[]))"/>
+  <line text="Method m() running"/>
+  </stdout>
+</run>
+</ajc-test>
+
+<ajc-test dir="bugs1612/pr239649" title="thisAspectInstance - 8">
+<compile files="Eight.java" options="-1.8"/>
+<run class="Eight">
+  <stdout>
+  <line text="in doit(): class=X"/>
+  <line text="In advice()"/>
+  <line text="Method m() running"/>
+  </stdout>
+</run>
+</ajc-test>
+
+<ajc-test dir="bugs1612/pr239649" title="thisAspectInstance - 9">
+<compile files="Nine.java" options="-1.8"/>
+<run class="Nine">
+  <stdout>
+  <line text="in doit(): class=X"/>
+  <line text="In advice()"/>
+  <line text="Method m() running"/>
+  </stdout>
+</run>
+</ajc-test>
+
+<ajc-test dir="bugs1612/pr239649" title="thisAspectInstance - 10">
+<compile files="Ten.java" options="-1.8"/>
+<run class="com.foo.bar.Ten">
+  <stdout>
+  <line text="In instance check method doit() class=com.foo.bar.X"/>
+  <line text="In advice()"/>
+  <line text="Method m() running"/>
+  </stdout>
+</run>
+</ajc-test>
+
+<ajc-test dir="bugs1612/pr239649" title="thisAspectInstance - 11">
+<compile files="Eleven.java" options="-1.8">
+<message kind="error" text="thisAspectInstance can only be used inside an if() clause for singleton aspects (compiler limitation)"/>
+</compile>
+</ajc-test>
+
+<ajc-test dir="bugs1612/pr239649" title="thisAspectInstance - 12">
+<compile files="Twelve.java" options="-1.8"/>
+<run class="Twelve">
+  <stdout>
+  <line text="In instance check method doit()"/>
+  <line text="In advice() arg=abc tjpsp=execution(void Twelve.m(String))"/>
+  <line text="Method m() running"/>
+  </stdout>
+</run>
+</ajc-test>
+
+<ajc-test dir="bugs1612/pr239649" title="thisAspectInstance - 13">
+<compile files="Thirteen.java" options="-1.8"/>
+<run class="Thirteen">
+  <stdout>
+  <line text="instance is X"/>
+  <line text="In advice() arg=abc tjpsp=execution(void Thirteen.m(String))"/>
+  <line text="Method m() running"/>
+  </stdout>
+</run>
+</ajc-test>
+
+<ajc-test dir="bugs1612/pr239649" title="thisAspectInstance - 14">
+<compile files="Fourteen.java" options="-1.8"/>
+<run class="Fourteen">
+  <stdout>
+  <line text="instance is X"/>
+  <line text="In advice()"/>
+  <line text="Method m() running"/>
+  </stdout>
+</run>
+</ajc-test>
+
+<ajc-test dir="bugs1612/pr239649" title="thisAspectInstance - 15">
+<compile files="Fifteen.java" options="-1.8"/>
+<run class="Fifteen">
+  <stdout>
+  <line text="in doit(): class=X"/>
+  <line text="In advice()"/>
+  <line text="Method m() running"/>
+  </stdout>
+</run>
+</ajc-test>
+
+</suite>