--- /dev/null
+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
// 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");}
</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
if (m_isTarget) {
return MAYBE;
} else {
- return node.getAnnotationTypePattern();
+ return new AnyWithAnnotationTypePattern( node.getAnnotationTypePattern());
}
}
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;