]> source.dussan.org Git - aspectj.git/commitdiff
Fix for 444398: annotation style abstract aspect extends class error
authorAndy Clement <aclement@gopivotal.com>
Wed, 17 Sep 2014 17:53:29 +0000 (10:53 -0700)
committerAndy Clement <aclement@gopivotal.com>
Wed, 17 Sep 2014 17:53:29 +0000 (10:53 -0700)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java
tests/bugs183/443477/Coo.java [new file with mode: 0644]
tests/bugs183/444398/Bottom.java [new file with mode: 0644]
tests/bugs183/444398/Middle.java [new file with mode: 0644]
tests/bugs183/444398/Top.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/AllTests18.java
tests/src/org/aspectj/systemtest/ajc183/Ajc183Tests.java
tests/src/org/aspectj/systemtest/ajc183/ajc183.xml

index 12ffdc9fc310868a374837b9d9462f46c5d5d0b3..d24ff7a3c0189a8e30321083291d45fc5c2469c1 100644 (file)
@@ -1031,6 +1031,10 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate {
 
        PerClause.Kind getPerClauseForTypeDeclaration(TypeDeclaration typeDeclaration) {
                Annotation[] annotations = typeDeclaration.annotations;
+               if (annotations == null) {
+                       // Can happen if an aspect is extending a regular class
+                       return null;
+               }
                for (int i = 0; i < annotations.length; i++) {
                        Annotation annotation = annotations[i];
                        if (annotation != null && annotation.resolvedType != null
@@ -1055,15 +1059,8 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate {
                                        // safe
                                        // ?
                                        return determinePerClause(typeDeclaration, clause);
-                               } else if (annotation instanceof NormalAnnotation) { // this
-                                       // kind
-                                       // if it
-                                       // was
-                                       // added
-                                       // by
-                                       // the
-                                       // visitor
-                                       // !
+                               } else if (annotation instanceof NormalAnnotation) { 
+                                       // this kind if it was added by the visitor!
                                        // it is an @Aspect(...something...)
                                        NormalAnnotation theAnnotation = (NormalAnnotation) annotation;
                                        if (theAnnotation.memberValuePairs == null || theAnnotation.memberValuePairs.length < 1) {
@@ -1080,8 +1077,7 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate {
                                                        "@Aspect annotation is expected to be SingleMemberAnnotation with 'String value()' as unique element",
                                                        new EclipseSourceLocation(typeDeclaration.compilationResult, typeDeclaration.sourceStart,
                                                                        typeDeclaration.sourceEnd), null);
-                                       return PerClause.SINGLETON;// fallback strategy just to
-                                       // avoid NPE
+                                       return PerClause.SINGLETON;// fallback strategy just to avoid NPE
                                }
                        }
                }
diff --git a/tests/bugs183/443477/Coo.java b/tests/bugs183/443477/Coo.java
new file mode 100644 (file)
index 0000000..7b514f3
--- /dev/null
@@ -0,0 +1,12 @@
+public class Coo {
+       Coo() { 
+       }
+       
+       public static void main(String[] args) {
+       }
+}
+
+aspect Azpect {
+    before(): !cflow(preinitialization(Coo.new(..))) && execution(* main(..)) {  }
+}
+
diff --git a/tests/bugs183/444398/Bottom.java b/tests/bugs183/444398/Bottom.java
new file mode 100644 (file)
index 0000000..b3d366a
--- /dev/null
@@ -0,0 +1,5 @@
+import org.aspectj.lang.annotation.*;
+
+@Aspect
+public abstract class Bottom extends Middle {
+}
diff --git a/tests/bugs183/444398/Middle.java b/tests/bugs183/444398/Middle.java
new file mode 100644 (file)
index 0000000..37c3e82
--- /dev/null
@@ -0,0 +1,6 @@
+import org.aspectj.lang.annotation.*;
+
+@Aspect
+
+public abstract class Middle extends Top {
+}
diff --git a/tests/bugs183/444398/Top.java b/tests/bugs183/444398/Top.java
new file mode 100644 (file)
index 0000000..a013d98
--- /dev/null
@@ -0,0 +1,2 @@
+public abstract class Top {
+}
index 5001f9a37db92fe8788c4a870e92dc13ec457867..547a1781794c6a41e9c2cd21e9d156e942322c0e 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2013 Contributors 
+ * Copyright (c) 2013, 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
@@ -16,12 +16,14 @@ import junit.framework.TestSuite;
 import org.aspectj.systemtest.ajc180.AllTestsAspectJ180;
 import org.aspectj.systemtest.ajc181.AllTestsAspectJ181;
 import org.aspectj.systemtest.ajc182.AllTestsAspectJ182; 
+import org.aspectj.systemtest.ajc183.AllTestsAspectJ183;
 
 public class AllTests18 {
 
        public static Test suite() {
                TestSuite suite = new TestSuite("AspectJ System Test Suite - 1.8");
                // $JUnit-BEGIN$ 
+               suite.addTest(AllTestsAspectJ183.suite()); 
                suite.addTest(AllTestsAspectJ182.suite()); 
                suite.addTest(AllTestsAspectJ181.suite()); 
                suite.addTest(AllTestsAspectJ180.suite()); 
index 80541fc0f17e8d0db2eaa923e1f76d1bb48d1b94..3c025711570d7545869ca95e8e71f88f0eb7977c 100644 (file)
@@ -21,9 +21,17 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
  */
 public class Ajc183Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
-       public void testAnnoStyleDecp_442425() {
-               runTest("anno style decp");
+       public void testAbstractAspectNPE_444398() {
+               runTest("abstract aspect npe");
        }
+       
+//     public void testVerifyError_443447() {
+//             runTest("verifyerror");
+//     }
+//     
+//     public void testAnnoStyleDecp_442425() {
+//             runTest("anno style decp");
+//     }
 
        // ---
 
index 5a77148b7c6fc4d5b5e119f050445466fc171e65..35bdca39669ae8f911844f87def85c48748a02f7 100644 (file)
@@ -2,6 +2,11 @@
 
 <suite>
 
+       <ajc-test dir="bugs183/444398" title="abstract aspect npe">
+               <compile options="-1.8" files="Bottom.java Middle.java Top.java">
+               </compile>
+       </ajc-test>
+       
        <ajc-test dir="bugs183/442425" title="anno style decp">
                <compile options="-1.8" files="EntityController.java IEntityController.java MyAnnotatedController.java EntityControllerAspect.java EntityMongoController.java">
                        <message kind="error" line="23" text="Type mismatch: cannot convert from MyAnnotatedController&lt;String&gt; to IEntityController&lt;String&gt;"/>
@@ -22,4 +27,9 @@
                -->
        </ajc-test>
        
+       <ajc-test dir="bugs183/443477" title="verifyerror">
+         <compile options="-1.7" files="Coo.java"/>
+         <run class="Coo"/>
+       </ajc-test>
+       
 </suite>