From c667bcb5088379d74b89c3dc8556b87429e4efb7 Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 26 Apr 2006 16:45:17 +0000 Subject: [PATCH] test and fix for 138286 --- tests/bugs152/pr138286/A.aj | 31 +++++++++++++++++++ .../systemtest/ajc152/Ajc152Tests.java | 2 ++ .../org/aspectj/systemtest/ajc152/ajc152.xml | 18 +++++++++++ .../PerThisOrTargetPointcutVisitor.java | 6 ++-- 4 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 tests/bugs152/pr138286/A.aj 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 @@ + + + + + + + + + + + + + + + + + + \ 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; -- 2.39.5