From f4c8433cb046e343b8491d04f0a10bd150924507 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Thu, 18 Feb 2016 12:08:06 -0800 Subject: [PATCH] Fix 433351: Declare parents fails on interfaces on the inpath depending on directory structure --- .../src/org/aspectj/weaver/ReferenceType.java | 3 +- .../src/org/aspectj/weaver/ResolvedType.java | 10 ++++++- tests/bugs189/433351/ClassProj1.java | 8 +++++ tests/bugs189/433351/ClassProj2.java | 9 ++++++ tests/{bugs181 => bugs189}/433351/Extender.aj | 0 tests/bugs189/433351/Extender2.aj | 10 +++++++ tests/bugs189/433351/Extender3.aj | 10 +++++++ .../433351/InterfaceProj1.java | 0 .../433351/InterfaceProj2.java | 0 .../systemtest/ajc181/Ajc181Tests.java | 4 --- .../org/aspectj/systemtest/ajc181/ajc181.xml | 7 ----- .../systemtest/ajc189/Ajc189Tests.java | 16 ++++++++++ .../systemtest/ajc189/AllTestsAspectJ189.java | 1 - .../org/aspectj/systemtest/ajc189/ajc189.xml | 29 +++++++++++++++++++ .../org/aspectj/weaver/bcel/BcelWeaver.java | 6 +++- 15 files changed, 98 insertions(+), 15 deletions(-) create mode 100644 tests/bugs189/433351/ClassProj1.java create mode 100644 tests/bugs189/433351/ClassProj2.java rename tests/{bugs181 => bugs189}/433351/Extender.aj (100%) create mode 100644 tests/bugs189/433351/Extender2.aj create mode 100644 tests/bugs189/433351/Extender3.aj rename tests/{bugs181 => bugs189}/433351/InterfaceProj1.java (100%) rename tests/{bugs181 => bugs189}/433351/InterfaceProj2.java (100%) diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java b/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java index 9791b8083..65fdf3a95 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java @@ -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(); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java index c053f5119..5985e4b6d 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java @@ -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/bugs189/433351/ClassProj1.java b/tests/bugs189/433351/ClassProj1.java new file mode 100644 index 000000000..ce06e88ab --- /dev/null +++ b/tests/bugs189/433351/ClassProj1.java @@ -0,0 +1,8 @@ +package test; + +public abstract class ClassProj1 implements InterfaceProj1 { + + public int aMethod() { + return 1; + } +} diff --git a/tests/bugs189/433351/ClassProj2.java b/tests/bugs189/433351/ClassProj2.java new file mode 100644 index 000000000..2aca8b08e --- /dev/null +++ b/tests/bugs189/433351/ClassProj2.java @@ -0,0 +1,9 @@ +package test.extender; + +public abstract class ClassProj2 implements InterfaceProj2 { + + public int bMethod() { + return 2; + } + +} diff --git a/tests/bugs181/433351/Extender.aj b/tests/bugs189/433351/Extender.aj similarity index 100% rename from tests/bugs181/433351/Extender.aj rename to tests/bugs189/433351/Extender.aj diff --git a/tests/bugs189/433351/Extender2.aj b/tests/bugs189/433351/Extender2.aj new file mode 100644 index 000000000..351c70eeb --- /dev/null +++ b/tests/bugs189/433351/Extender2.aj @@ -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 index 000000000..9fcda9e52 --- /dev/null +++ b/tests/bugs189/433351/Extender3.aj @@ -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/bugs181/433351/InterfaceProj1.java b/tests/bugs189/433351/InterfaceProj1.java similarity index 100% rename from tests/bugs181/433351/InterfaceProj1.java rename to tests/bugs189/433351/InterfaceProj1.java diff --git a/tests/bugs181/433351/InterfaceProj2.java b/tests/bugs189/433351/InterfaceProj2.java similarity index 100% rename from tests/bugs181/433351/InterfaceProj2.java rename to tests/bugs189/433351/InterfaceProj2.java diff --git a/tests/src/org/aspectj/systemtest/ajc181/Ajc181Tests.java b/tests/src/org/aspectj/systemtest/ajc181/Ajc181Tests.java index a15231dcf..3aa41837e 100644 --- a/tests/src/org/aspectj/systemtest/ajc181/Ajc181Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc181/Ajc181Tests.java @@ -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"); diff --git a/tests/src/org/aspectj/systemtest/ajc181/ajc181.xml b/tests/src/org/aspectj/systemtest/ajc181/ajc181.xml index 314aaf712..1a8b1acfc 100644 --- a/tests/src/org/aspectj/systemtest/ajc181/ajc181.xml +++ b/tests/src/org/aspectj/systemtest/ajc181/ajc181.xml @@ -2,13 +2,6 @@ - - - - - - - diff --git a/tests/src/org/aspectj/systemtest/ajc189/Ajc189Tests.java b/tests/src/org/aspectj/systemtest/ajc189/Ajc189Tests.java index a3a191a61..456c4a41f 100644 --- a/tests/src/org/aspectj/systemtest/ajc189/Ajc189Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc189/Ajc189Tests.java @@ -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"); } diff --git a/tests/src/org/aspectj/systemtest/ajc189/AllTestsAspectJ189.java b/tests/src/org/aspectj/systemtest/ajc189/AllTestsAspectJ189.java index 0ccf75cf2..546ef02de 100644 --- a/tests/src/org/aspectj/systemtest/ajc189/AllTestsAspectJ189.java +++ b/tests/src/org/aspectj/systemtest/ajc189/AllTestsAspectJ189.java @@ -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 { diff --git a/tests/src/org/aspectj/systemtest/ajc189/ajc189.xml b/tests/src/org/aspectj/systemtest/ajc189/ajc189.xml index 586ff771e..8693c1e24 100644 --- a/tests/src/org/aspectj/systemtest/ajc189/ajc189.xml +++ b/tests/src/org/aspectj/systemtest/ajc189/ajc189.xml @@ -2,6 +2,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java index 5e524549e..e3e97517a 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java @@ -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(); -- 2.39.5