]> source.dussan.org Git - aspectj.git/commitdiff
Fix 433351: Declare parents fails on interfaces on the inpath depending on directory...
authorAndy Clement <aclement@pivotal.io>
Thu, 18 Feb 2016 20:08:06 +0000 (12:08 -0800)
committerAndy Clement <aclement@pivotal.io>
Thu, 18 Feb 2016 20:08:06 +0000 (12:08 -0800)
18 files changed:
org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
tests/bugs181/433351/Extender.aj [deleted file]
tests/bugs181/433351/InterfaceProj1.java [deleted file]
tests/bugs181/433351/InterfaceProj2.java [deleted file]
tests/bugs189/433351/ClassProj1.java [new file with mode: 0644]
tests/bugs189/433351/ClassProj2.java [new file with mode: 0644]
tests/bugs189/433351/Extender.aj [new file with mode: 0644]
tests/bugs189/433351/Extender2.aj [new file with mode: 0644]
tests/bugs189/433351/Extender3.aj [new file with mode: 0644]
tests/bugs189/433351/InterfaceProj1.java [new file with mode: 0644]
tests/bugs189/433351/InterfaceProj2.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc181/Ajc181Tests.java
tests/src/org/aspectj/systemtest/ajc181/ajc181.xml
tests/src/org/aspectj/systemtest/ajc189/Ajc189Tests.java
tests/src/org/aspectj/systemtest/ajc189/AllTestsAspectJ189.java
tests/src/org/aspectj/systemtest/ajc189/ajc189.xml
weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java

index 9791b80834f856f7b36aadd83200363d34b7707d..65fdf3a95da9af12d723cfefc2a75273b915f067 100644 (file)
@@ -1161,6 +1161,7 @@ public class ReferenceType extends ResolvedType {
                annotations = null;
                annotationTypes = null;
                newSuperclass = null;
+               bits = 0; // clears the hierarchy complete tag (amongst other things)
                newInterfaces = null;
                typeVariables = null;
                parameterizedInterfaces.clear();
@@ -1168,7 +1169,7 @@ public class ReferenceType extends ResolvedType {
                if (getDelegate() != null) {
                        delegate.ensureConsistent();
                }
-               if (isRawType()) {
+               if (isParameterizedOrRawType()) {
                        ReferenceType genericType = getGenericType();
                        if (genericType != null) {
                                genericType.ensureConsistent();
index c053f511985fba7d861b93f03d761aa8a9cc282d..5985e4b6dd42161e01615fc5528fa0ebef941a77 100644 (file)
@@ -50,7 +50,7 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
 
        protected World world;
 
-       private int bits;
+       protected int bits;
 
        private static int AnnotationBitsInitialized = 0x0001;
        private static int AnnotationMarkedInherited = 0x0002;
@@ -2803,10 +2803,18 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
        }
 
        public void tagAsTypeHierarchyComplete() {
+               if (isParameterizedOrRawType()) {
+                       ReferenceType genericType = this.getGenericType();
+                       genericType.tagAsTypeHierarchyComplete();
+                       return;
+               }
                bits |= TypeHierarchyCompleteBit;
        }
 
        public boolean isTypeHierarchyComplete() {
+               if (isParameterizedOrRawType()) {
+                       return this.getGenericType().isTypeHierarchyComplete();
+               }
                return (bits & TypeHierarchyCompleteBit) != 0;
        }
 
diff --git a/tests/bugs181/433351/Extender.aj b/tests/bugs181/433351/Extender.aj
deleted file mode 100644 (file)
index 4332756..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-package test.extender;
-import test.*;
-
-public aspect Extender {
-
-       declare parents: InterfaceProj1 extends InterfaceProj2;
-
-//     declare parents: test.ClassProj1 extends ClassProj2;
-
-}
diff --git a/tests/bugs181/433351/InterfaceProj1.java b/tests/bugs181/433351/InterfaceProj1.java
deleted file mode 100644 (file)
index 7d90bef..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package test;
-
-public interface InterfaceProj1<T> {
-
-       public abstract int aMethod();
-       
-}
diff --git a/tests/bugs181/433351/InterfaceProj2.java b/tests/bugs181/433351/InterfaceProj2.java
deleted file mode 100644 (file)
index b6846f5..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package test.extender;
-
-public interface InterfaceProj2<T> {
-
-       public abstract int bMethod();
-       
-}
\ No newline at end of file
diff --git a/tests/bugs189/433351/ClassProj1.java b/tests/bugs189/433351/ClassProj1.java
new file mode 100644 (file)
index 0000000..ce06e88
--- /dev/null
@@ -0,0 +1,8 @@
+package test;
+
+public abstract class ClassProj1<T> implements InterfaceProj1<String> {
+
+       public int aMethod() {
+               return 1;
+       }
+}
diff --git a/tests/bugs189/433351/ClassProj2.java b/tests/bugs189/433351/ClassProj2.java
new file mode 100644 (file)
index 0000000..2aca8b0
--- /dev/null
@@ -0,0 +1,9 @@
+package test.extender;
+
+public abstract class ClassProj2<T> implements InterfaceProj2<T> {
+
+       public int bMethod() {
+               return 2;
+       }
+       
+}
diff --git a/tests/bugs189/433351/Extender.aj b/tests/bugs189/433351/Extender.aj
new file mode 100644 (file)
index 0000000..4332756
--- /dev/null
@@ -0,0 +1,10 @@
+package test.extender;
+import test.*;
+
+public aspect Extender {
+
+       declare parents: InterfaceProj1 extends InterfaceProj2;
+
+//     declare parents: test.ClassProj1 extends ClassProj2;
+
+}
diff --git a/tests/bugs189/433351/Extender2.aj b/tests/bugs189/433351/Extender2.aj
new file mode 100644 (file)
index 0000000..351c70e
--- /dev/null
@@ -0,0 +1,10 @@
+package test.extender;
+import test.*;
+
+public aspect Extender2 {
+
+       declare parents: InterfaceProj1 extends java.io.Serializable;
+
+//     declare parents: test.ClassProj1 extends ClassProj2;
+
+}
diff --git a/tests/bugs189/433351/Extender3.aj b/tests/bugs189/433351/Extender3.aj
new file mode 100644 (file)
index 0000000..9fcda9e
--- /dev/null
@@ -0,0 +1,10 @@
+package test.extender;
+import test.*;
+
+public aspect Extender3 {
+
+       declare parents: InterfaceProj1 extends InterfaceProj2;
+
+       declare parents: test.ClassProj1 extends ClassProj2;
+
+}
diff --git a/tests/bugs189/433351/InterfaceProj1.java b/tests/bugs189/433351/InterfaceProj1.java
new file mode 100644 (file)
index 0000000..7d90bef
--- /dev/null
@@ -0,0 +1,7 @@
+package test;
+
+public interface InterfaceProj1<T> {
+
+       public abstract int aMethod();
+       
+}
diff --git a/tests/bugs189/433351/InterfaceProj2.java b/tests/bugs189/433351/InterfaceProj2.java
new file mode 100644 (file)
index 0000000..b6846f5
--- /dev/null
@@ -0,0 +1,7 @@
+package test.extender;
+
+public interface InterfaceProj2<T> {
+
+       public abstract int bMethod();
+       
+}
\ No newline at end of file
index a15231dcf544f7ccb8d1f0460916be29974226fc..3aa41837e5d1efb2da2ed94ee532061689075b0a 100644 (file)
@@ -21,10 +21,6 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
  * @author Andy Clement
  */
 public class Ajc181Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
-
-       public void testJarWeaving_433351() {
-               runTest("jar weaving");
-       }
        
        public void testParameterNamesAttribute_436531() {
                runTest("parameter names attribute");
index 314aaf712e4306e013079c90ce5b0c06d20c3494..1a8b1acfcb538cb13d6f241c8dd02bfa718bef8d 100644 (file)
@@ -2,13 +2,6 @@
 
 <suite>
 
-       <ajc-test dir="bugs181/433351" title="jar weaving">
-               <compile options="-1.5" files="InterfaceProj1.java" outjar="code.jar"/>
-               <compile options="-1.5 -showWeaveInfo" inpath="code.jar" files="Extender.aj InterfaceProj2.java">
-               <message kind="weave" text="Extending interface set for type 'test.InterfaceProj1' (InterfaceProj1.java) to include 'test.extender.InterfaceProj2' (Extender.aj)"/>
-               </compile>
-       </ajc-test>
-
        <ajc-test dir="bugs181/436531" title="parameter names attribute">
                <compile options="-1.8" files="Azpect.java" inpath="code.jar"/>
        </ajc-test>
index a3a191a616913bfe1a0eb551ade4052cba113379..456c4a41f5d5c9c2f8ac39a645a9a0cea5a177aa 100644 (file)
@@ -22,6 +22,22 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
  */
 public class Ajc189Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
+       public void testJarWeaving_433351() {
+               runTest("jar weaving");
+       }
+       
+       public void testJarWeaving_433351_4() {
+               runTest("jar weaving 4");
+       }
+
+       public void testJarWeaving_433351_3() {
+               runTest("jar weaving 3");
+       }
+
+       public void testJarWeaving_433351_2() {
+               runTest("jar weaving 2");
+       }
+       
        public void testNPEAtAspectJ() throws Exception {
                runTest("NPE at aspectj");
        }
index 0ccf75cf2a78c2bd219cd3cb3f4cda19c947e7f2..546ef02de751383a377c55f6c5f25b038ca5a63e 100644 (file)
@@ -12,7 +12,6 @@ package org.aspectj.systemtest.ajc189;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
-import org.aspectj.systemtest.apt.AptTests;
 
 public class AllTestsAspectJ189 {
 
index 586ff771eaeebcb2c9f012533696a665ba0872fa..8693c1e24d0b26c139a38892fbd3110d0f4ae295 100644 (file)
@@ -2,6 +2,35 @@
 
 <suite>
 
+       <ajc-test dir="bugs189/433351" title="jar weaving">
+               <compile options="-1.5" files="InterfaceProj1.java" outjar="code.jar"/>
+               <compile options="-1.5 -showWeaveInfo" inpath="code.jar" files="Extender.aj InterfaceProj2.java">
+               <message kind="weave" text="Extending interface set for type 'test.InterfaceProj1' (InterfaceProj1.java) to include 'test.extender.InterfaceProj2' (Extender.aj)"/>
+               </compile>
+       </ajc-test>
+
+       <ajc-test dir="bugs189/433351" title="jar weaving 2">
+               <compile options="-1.5" files="InterfaceProj1.java ClassProj1.java" outjar="code.jar"/>
+               <compile options="-1.5 -showWeaveInfo" inpath="code.jar" files="Extender2.aj" outjar="code2.jar">
+               <message kind="weave" text="Extending interface set for type 'test.InterfaceProj1' (InterfaceProj1.java) to include 'java.io.Serializable' (Extender2.aj)"/>
+               </compile>
+       </ajc-test>
+
+       <ajc-test dir="bugs189/433351" title="jar weaving 3">
+               <compile options="-1.5" files="InterfaceProj1.java ClassProj1.java" outjar="code.jar"/>
+               <compile options="-1.5 -showWeaveInfo" inpath="code.jar" files="Extender3.aj InterfaceProj2.java ClassProj2.java" outjar="code2.jar">
+               <message kind="weave" text="Setting superclass of type 'test.ClassProj1' (ClassProj1.java) to 'test.extender.ClassProj2' (Extender3.aj)"/>
+               <message kind="weave" text="Extending interface set for type 'test.InterfaceProj1' (InterfaceProj1.java) to include 'test.extender.InterfaceProj2' (Extender3.aj)"/>
+               </compile>
+       </ajc-test>
+       
+       <ajc-test dir="bugs189/433351" title="jar weaving 4">
+               <compile options="-1.5" files="ClassProj1.java InterfaceProj1.java" outjar="code.jar"/>
+               <compile options="-1.5 -showWeaveInfo" inpath="code.jar" files="Extender2.aj" outjar="code2.jar">
+               <message kind="weave" text="Extending interface set for type 'test.InterfaceProj1' (InterfaceProj1.java) to include 'java.io.Serializable' (Extender2.aj)"/>
+               </compile>
+       </ajc-test>
+       
 <ajc-test dir="bugs189/485583" title="NPE at aspectj">
   <compile files="Foo.aj Bar.aj" options="-1.8">
   <message kind="error" text="The abstract pointcut deprecatedCode can only be defined in an aspect"/>
index 5e524549e1ee41defd7fbdacf661bf5a3a7b0feb..e3e97517a758bfb4dbf9ad7532a0557112a17dc5 100644 (file)
@@ -1323,7 +1323,11 @@ public class BcelWeaver {
                }
                ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_DECLARE_PARENTS,
                                resolvedTypeToWeave.getName());
-               weaveParentTypeMungers(resolvedTypeToWeave);
+               // If A was processed before B (and was declared 'class A implements B') then there is no need to complete B again, it 
+               // will have been done whilst processing A.
+               if (!resolvedTypeToWeave.isTypeHierarchyComplete()) {
+                       weaveParentTypeMungers(resolvedTypeToWeave);
+               }
                CompilationAndWeavingContext.leavingPhase(tok);
                typesForWeaving.remove(typeToWeave);
                resolvedTypeToWeave.tagAsTypeHierarchyComplete();