diff options
author | aclement <aclement> | 2006-05-12 10:41:42 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-05-12 10:41:42 +0000 |
commit | 3ca976f0ce48a49cdcef98b7f72ce2ce23b9ef4d (patch) | |
tree | 85c2c9f8a90b59f2716fb80d9df2e4c360105e57 | |
parent | 5d2b5b8892cc6e714565326b70d7c6a4b7007129 (diff) | |
download | aspectj-3ca976f0ce48a49cdcef98b7f72ce2ce23b9ef4d.tar.gz aspectj-3ca976f0ce48a49cdcef98b7f72ce2ce23b9ef4d.zip |
test and fix for 129704: broken @annotation for methods in generic types
-rw-r--r-- | tests/bugs152/pr129704/A.java | 19 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java | 1 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc152/ajc152.xml | 9 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/BcelShadow.java | 7 |
4 files changed, 33 insertions, 3 deletions
diff --git a/tests/bugs152/pr129704/A.java b/tests/bugs152/pr129704/A.java new file mode 100644 index 000000000..a2e213cca --- /dev/null +++ b/tests/bugs152/pr129704/A.java @@ -0,0 +1,19 @@ +import java.lang.annotation.*; + +interface GDO {} + +@Retention(RetentionPolicy.RUNTIME) @interface Marker { } + +class DCP<T extends GDO> { + @Marker void getData(){} +} + +aspect X { + before(Marker a): execution(* getData(..)) && @annotation(a) { System.err.println(a); } +} + +public class A { + public static void main(String[] args) { + new DCP().getData(); + } +}
\ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java b/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java index bb6e4994c..bc369eca7 100644 --- a/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java @@ -17,6 +17,7 @@ import org.aspectj.testing.XMLBasedAjcTestCase; public class Ajc152Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + public void testAnnotationsAndGenericsBCException_pr129704() { runTest("annotations and generics leading to BCException");} public void testMethodTooBigAfterWeaving_pr138384() { runTest("method too big"); } public void testNotAtWithincode_pr138158_1() { runTest("not at withincode - 1");} public void testNotAtWithincode_pr138158_2() { runTest("not at withincode - 2");} diff --git a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml index eb90cdda9..ce82b82eb 100644 --- a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml +++ b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml @@ -15,6 +15,15 @@ </run> </ajc-test> + <ajc-test dir="bugs152/pr129704" title="annotations and generics leading to BCException"> + <compile files="A.java" options="-1.5"/> + <run class="A"> + <stderr> + <line text="@Marker()"/> + </stderr> + </run> + </ajc-test> + <ajc-test dir="bugs152/pr136258" title="stack overflow"> <compile files="StatisticsTypeImpl.java" options="-1.5"/> <run class="StatisticsTypeImpl"/> diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java index b201b039c..7b2678f63 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java @@ -1559,8 +1559,9 @@ public class BcelShadow extends Shadow { ResolvedType[] annotations = null; Member relevantMember = getSignature(); ResolvedType relevantType = relevantMember.getDeclaringType().resolve(world); - - if (getKind() == Shadow.StaticInitialization) { + if (relevantType.isRawType() || relevantType.isParameterizedType()) relevantType = relevantType.getGenericType(); + + if (getKind() == Shadow.StaticInitialization) { annotations = relevantType.resolve(world).getAnnotationTypes(); } else if (getKind() == Shadow.MethodCall || getKind() == Shadow.ConstructorCall) { @@ -1596,7 +1597,7 @@ public class BcelShadow extends Shadow { //ResolvedMember rm[] = relevantType.getDeclaredMethods(); Member foundMember = findMethod2(relevantType.getDeclaredMethods(),getSignature()); - annotations = getAnnotations(foundMember, relevantMember,relevantType); + annotations = getAnnotations(foundMember, relevantMember, relevantType); relevantMember = foundMember; relevantMember = getRelevantMember(foundMember, relevantMember,relevantType); |