]> source.dussan.org Git - aspectj.git/commitdiff
work in progress bug433351
authorAndy Clement <aclement@gopivotal.com>
Thu, 19 Jun 2014 23:40:17 +0000 (16:40 -0700)
committerAndy Clement <aclement@gopivotal.com>
Thu, 19 Jun 2014 23:40:17 +0000 (16:40 -0700)
org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
tests/bugs181/433351/ClassProj1.java [new file with mode: 0644]
tests/bugs181/433351/ClassProj2.java [new file with mode: 0644]
tests/bugs181/433351/Extender2.aj [new file with mode: 0644]
tests/bugs181/433351/Extender3.aj [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc181/Ajc181Tests.java
tests/src/org/aspectj/systemtest/ajc181/ajc181.xml
weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java

index 538bd940fd499ed2dbcbb6bb11c701164c93630a..8912505259b74614b15d2a869e8f1693fb0c78a0 100644 (file)
@@ -1156,6 +1156,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();
@@ -1163,7 +1164,7 @@ public class ReferenceType extends ResolvedType {
                if (getDelegate() != null) {
                        delegate.ensureConsistent();
                }
-               if (isRawType()) {
+               if (isParameterizedOrRawType()) {
                        ReferenceType genericType = getGenericType();
                        if (genericType != null) {
                                genericType.ensureConsistent();
index 9746fea813dd8815e0a5fea28b382bd601541554..688a5aa3dac25efd47e451f2769e156caa8cfdf7 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;
@@ -2798,10 +2798,19 @@ 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()) {
+                       ReferenceType genericType = this.getGenericType();
+                       return genericType.isTypeHierarchyComplete();
+               }
                return (bits & TypeHierarchyCompleteBit) != 0;
        }
 
diff --git a/tests/bugs181/433351/ClassProj1.java b/tests/bugs181/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/bugs181/433351/ClassProj2.java b/tests/bugs181/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/bugs181/433351/Extender2.aj b/tests/bugs181/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/bugs181/433351/Extender3.aj b/tests/bugs181/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;
+
+}
index 24c07b03f5c35ab05ec5d0c11b95b620ea472d4b..44120eb4750d4cd8ee529125fa804f3f4b01c4c0 100644 (file)
@@ -22,6 +22,18 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
  */
 public class Ajc181Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
+       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 testJarWeaving_433351() {
                runTest("jar weaving");
        }
index 314aaf712e4306e013079c90ce5b0c06d20c3494..576c741f6d040594742fd92452555186af6704ce 100644 (file)
@@ -3,12 +3,34 @@
 <suite>
 
        <ajc-test dir="bugs181/433351" title="jar weaving">
-               <compile options="-1.5" files="InterfaceProj1.java" outjar="code.jar"/>
+               <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/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="bugs181/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="bugs181/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="bugs181/436531" title="parameter names attribute">
                <compile options="-1.8" files="Azpect.java" inpath="code.jar"/>
        </ajc-test>
index 815becde0541480866123e8e8b330789ad393408..ee232d082140e0218168ddab1952d2689bdfe739 100644 (file)
@@ -1297,6 +1297,10 @@ public class BcelWeaver {
                        // resolve it if the caller could not pass in the resolved type
                        resolvedTypeToWeave = world.resolve(typeToWeave);
                }
+//             if (resolvedTypeToWeave.isTypeHierarchyComplete()) {
+//                     typesForWeaving.remove(typeToWeave);
+//                     return;
+//             }
                ResolvedType superclassType = resolvedTypeToWeave.getSuperclass();
                String superclassTypename = (superclassType == null ? null : superclassType.getName());
 
@@ -1319,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();