diff options
author | aclement <aclement> | 2006-04-26 16:45:17 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-04-26 16:45:17 +0000 |
commit | c667bcb5088379d74b89c3dc8556b87429e4efb7 (patch) | |
tree | e9d296ba9f3347c7484fe2a35445b1956d3f4068 | |
parent | 99882cb91a94c468c185cf11cd6a728604e95bdb (diff) | |
download | aspectj-c667bcb5088379d74b89c3dc8556b87429e4efb7.tar.gz aspectj-c667bcb5088379d74b89c3dc8556b87429e4efb7.zip |
test and fix for 138286
4 files changed, 54 insertions, 3 deletions
diff --git a/tests/bugs152/pr138286/A.aj b/tests/bugs152/pr138286/A.aj new file mode 100644 index 000000000..2c20ea79f --- /dev/null +++ b/tests/bugs152/pr138286/A.aj @@ -0,0 +1,31 @@ +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.*; + +@Retention(RUNTIME) +@Inherited +@interface MyAnnotation {} + +public aspect A perthis(annotatedClasses()) { + + pointcut annotatedClasses() : @this(MyAnnotation); + + before(): initialization(*.new(..)) {System.err.println(thisJoinPoint.getSignature().getDeclaringType()); } + + public static void main(String []argv) { + new Foo(); + new Goo(); + new Boo(); + new Soo(); + } +} + +// yes/no indicates if runtime match expected for staticinitialization + +@MyAnnotation class Foo { } // YES + +class Goo { } // NO + +@MyAnnotation class Boo { } // YES + +class Soo extends Boo { } // YES
\ 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 4026dc802..261cc4f8b 100644 --- a/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java @@ -38,6 +38,8 @@ public class Ajc152Tests extends org.aspectj.testing.XMLBasedAjcTestCase { // public void testReferencePCutInPerClause_pr138219() { runTest("Can't use a FQ Reference pointcut in any pointcut expression referenced by a per-clause");} // public void testDoubleAnnotationMatching_pr138223() { runTest("Double at annotation matching (no binding)");} + public void testNoClassCastExceptionWithPerThis_pr138286() { runTest("No ClassCastException with perThis");} + // this next one reported as a bug by Rob Harrop, but I can't reproduce the failure yet... //public void testAtAspectWithReferencePCPerClause_pr138220() { runTest("@Aspect with reference pointcut in perclause");} diff --git a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml index cb7cd1fe1..0d49de371 100644 --- a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml +++ b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml @@ -165,4 +165,22 @@ </compile> </ajc-test> + <ajc-test dir="bugs152/pr138286" pr="138286" title="No ClassCastException with perThis"> + <compile files="A.aj" options="-1.5 -showWeaveInfo"> + <message kind="weave" text="Join point 'initialization(void A.<init>())' in Type 'A' (A.aj:9) advised by before advice from 'A' (A.aj:13) [with runtime test]"/> + <message kind="weave" text="Join point 'initialization(void Soo.<init>())' in Type 'Soo' (A.aj:31) advised by before advice from 'A' (A.aj:13) [with runtime test]"/> + <message kind="weave" text="Join point 'initialization(void Goo.<init>())' in Type 'Goo' (A.aj:27) advised by before advice from 'A' (A.aj:13) [with runtime test]"/> + <message kind="weave" text="Join point 'initialization(void Foo.<init>())' in Type 'Foo' (A.aj:25) advised by before advice from 'A' (A.aj:13) [with runtime test]"/> + <message kind="weave" text="Join point 'initialization(void Boo.<init>())' in Type 'Boo' (A.aj:29) advised by before advice from 'A' (A.aj:13) [with runtime test]"/> + </compile> + <run class="A"> + <stderr> + <line text="class Foo"/> + <line text="class Boo"/> + <line text="class Boo"/> <!-- this one is because of the super() call in Soo's default ctor --> + <line text="class Soo"/> + </stderr> + </run> + </ajc-test> + </suite>
\ No newline at end of file diff --git a/weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java b/weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java index 0d3cb2a5f..8a6665df2 100644 --- a/weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java +++ b/weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java @@ -67,7 +67,7 @@ public class PerThisOrTargetPointcutVisitor extends IdentityPointcutVisitor { if (m_isTarget) { return MAYBE; } else { - return node.getAnnotationTypePattern(); + return new AnyWithAnnotationTypePattern( node.getAnnotationTypePattern()); } } @@ -125,9 +125,9 @@ public class PerThisOrTargetPointcutVisitor extends IdentityPointcutVisitor { public Object visit(ThisOrTargetAnnotationPointcut node, Object data) { if (m_isTarget && !node.isThis()) { - return node.getAnnotationTypePattern(); + return new AnyWithAnnotationTypePattern( node.getAnnotationTypePattern()); } else if (!m_isTarget && node.isThis()) { - return node.getAnnotationTypePattern(); + return new AnyWithAnnotationTypePattern( node.getAnnotationTypePattern()); } else { // perthis(@target(Foo)) return MAYBE; |