From f37c56e02982a1043e7821bf033b58495f8a6b74 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Fri, 2 Mar 2012 08:17:44 -0800 Subject: [PATCH] fix for 371998 Use resolved type pattern rather than re-resolving --- tests/bugs170/pr371998/AspectTest.java | 32 +++++++++++++++++++ .../systemtest/ajc170/Ajc170Tests.java | 13 +++----- .../org/aspectj/systemtest/ajc170/ajc170.xml | 10 ++++++ .../aspectj/weaver/bcel/AtAjAttributes.java | 9 ++---- 4 files changed, 49 insertions(+), 15 deletions(-) create mode 100644 tests/bugs170/pr371998/AspectTest.java diff --git a/tests/bugs170/pr371998/AspectTest.java b/tests/bugs170/pr371998/AspectTest.java new file mode 100644 index 000000000..38bc68ee2 --- /dev/null +++ b/tests/bugs170/pr371998/AspectTest.java @@ -0,0 +1,32 @@ +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.DeclareParents; + +@Aspect +public class AspectTest { + + public AspectTest() {} + + @DeclareParents(value="java.lang.Runnable+ || java.util.concurrent.Callable+", defaultImpl=XImpl.class) + //@DeclareParents(value="java.lang.Runnable+", defaultImpl=XImpl.class) + private X xImpl; + + public static void main(String []argv) { + ((X)new Foo()).xxx(); + ((X)new Bar()).xxx(); + } + +} + interface X { void xxx();} + class XImpl implements X { + public XImpl() {} + public void xxx() {} + } + + +class Foo implements Runnable { + public void run() {} +} + +class Bar implements java.util.concurrent.Callable { + public Object call() {return null;} +} diff --git a/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java b/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java index 4e40d4162..84add7bc6 100644 --- a/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java @@ -11,27 +11,22 @@ package org.aspectj.systemtest.ajc170; import java.io.File; -import java.util.List; import junit.framework.Test; -import org.aspectj.apache.bcel.util.ClassPath; import org.aspectj.testing.XMLBasedAjcTestCase; -import org.aspectj.weaver.CrosscuttingMembers; -import org.aspectj.weaver.ReferenceType; -import org.aspectj.weaver.ResolvedMember; -import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.TypeFactory; -import org.aspectj.weaver.TypeVariable; import org.aspectj.weaver.UnresolvedType; -import org.aspectj.weaver.World; -import org.aspectj.weaver.bcel.BcelWorld; /** * @author Andy Clement */ public class Ajc170Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + public void testBCExceptionAnnoDecp_371998() { + runTest("BCException anno decp"); + } + public void testGenericsWithTwoTypeParamsOneWildcard() { UnresolvedType ut; diff --git a/tests/src/org/aspectj/systemtest/ajc170/ajc170.xml b/tests/src/org/aspectj/systemtest/ajc170/ajc170.xml index 8a6c34c53..8d4eedacf 100644 --- a/tests/src/org/aspectj/systemtest/ajc170/ajc170.xml +++ b/tests/src/org/aspectj/systemtest/ajc170/ajc170.xml @@ -2,6 +2,16 @@ + + + + + + + + + + diff --git a/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java b/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java index c4e519715..41f9f1ab7 100644 --- a/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java +++ b/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java @@ -66,7 +66,6 @@ import org.aspectj.weaver.UnresolvedType; import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.WeaverMessages; import org.aspectj.weaver.World; -import org.aspectj.weaver.patterns.Bindings; import org.aspectj.weaver.patterns.DeclareErrorOrWarning; import org.aspectj.weaver.patterns.DeclareParents; import org.aspectj.weaver.patterns.DeclareParentsMixin; @@ -735,15 +734,13 @@ public class AtAjAttributes { List parents = new ArrayList(1); parents.add(parent); DeclareParents dp = new DeclareParents(typePattern, parents, false); - dp.resolve(binding); // resolves the parent and child parts - // of the decp + dp.resolve(binding); // resolves the parent and child parts of the decp // resolve this so that we can use it for the // MethodDelegateMungers below. // eg. '@Coloured *' will change from a WildTypePattern to - // an 'AnyWithAnnotationTypePattern' after this - // resolution - typePattern = typePattern.resolveBindings(binding, Bindings.NONE, false, false); + // an 'AnyWithAnnotationTypePattern' after this resolution + typePattern = dp.getChild(); // this retrieves the resolved version // TODO kick ISourceLocation sl = // struct.bField.getSourceLocation(); ?? // dp.setLocation(dp.getDeclaringType().getSourceContext(), -- 2.39.5