--- /dev/null
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @interface Ann {}
+
+
+aspect Aspect {
+
+ // Call to an annotated method
+ pointcut annotated(Ann b) : call(@Ann * *(..)) && @annotation(b);
+
+ // Top level call to an annotated method
+ pointcut annotatedTop(Ann b) : annotated(b) && !cflowbelow(annotated(Ann));
+
+ // Non top level call
+ pointcut annotatedNotTop(Ann b, Ann bTopo) :
+ annotated(b) && cflowbelow(annotatedTop(bTopo));
+
+ before(Ann b, Ann bTopo) : annotatedNotTop(b, bTopo) {
+ System.out.println("\tJoin point: " + thisJoinPointStaticPart);
+ }
+
+ // Methods with out the Ann annotation but in an Ann annotated type get Ann
+ declare @method: !@Ann * (@Ann *).*(..) : @Ann;
+}
+
+public class A {
+ @Ann void foo() { new B().foo(); new B().goo();}
+ public static void main(String[] args) { new A().foo(); }
+}
+
--- /dev/null
+
+@Ann class B {
+ //@Ann
+ void foo() { }
+ void goo() { }
+}
\ No newline at end of file
--- /dev/null
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @interface Ann {String value();}
+
+aspect Aspect {
+
+ // Methods with out the Ann annotation but in an Ann annotated type get Ann
+// declare @method: !@Ann * (@Ann *).*(..) : @Ann("introduced");
+
+ // Call to an annotated method
+ pointcut annotated(Ann b) : call(@Ann * *(..)) && @annotation(b);
+
+ // Top level call to an annotated method
+ pointcut annotatedTop(Ann b) : annotated(b) && !cflowbelow(annotated(Ann));
+
+ // Non top level call
+ pointcut annotatedNotTop(Ann b, Ann bTopo) :
+ annotated(b) && cflowbelow(annotatedTop(bTopo));
+
+ before(Ann b, Ann bTopo) :
+ annotatedNotTop(b, bTopo) {
+ System.out.println("Non-top:");
+ System.out.println("\tJoin point: " + thisJoinPointStaticPart);
+ System.out.println("\tEnclosing join point: " + thisEnclosingJoinPointStaticPart);
+ System.out.println("\tAnn: " + b);
+ System.out.println("\tTop annotation: " + bTopo);
+ }
+
+// before(Ann b) :
+// annotatedTop(b) {
+// System.out.println("Top:");
+// System.out.println("\tJoin point: " + thisJoinPointStaticPart);
+// System.out.println("\tEnclosing join point: " +
+//thisEnclosingJoinPointStaticPart);
+// System.out.println("\tAnn: " + b);
+// }
+// declare @method: !@Ann * (@Ann *).*(..) : @Ann("introduced");
+ declare @method: * B.goo() : @Ann("introduced");
+}
+
+public class A {
+ @Ann("A.foo") void foo() { new B().foo(); new B().goo();}
+ public static void main(String[] args) { new A().foo(); }
+}
+
+@Ann("B") class B {
+ // The Ann is injected here!
+ @Ann("B.foo")
+ void foo() { }
+ void goo() { }
+}
--- /dev/null
+abstract aspect A {
+ abstract pointcut p();
+ before(): p() {
+ System.err.println("advice");
+ }
+}
--- /dev/null
+public class C {
+ public static void main(String []argv) {
+ new C().foo();
+ }
+ public void foo() {System.err.println("foo running");}
+}
+
+
--- /dev/null
+<aspectj>
+ <weaver options="-Xnoinline"/>
+ <aspects>
+ <concrete-aspect name="AA"
+ extends="A">
+
+ <pointcut name="p" expression="within(SomeType) AND execution(* foo(..))" />
+
+ </concrete-aspect>
+ </aspects>
+</aspectj>
--- /dev/null
+<aspectj>
+ <weaver options="-Xnoinline"/>
+ <aspects>
+ <concrete-aspect name="AA"
+ extends="A">
+
+ <pointcut name="p" expression="(within(*) AND (call(java.lang.String*.new(..)) || call(java.lang.Object.new(..))) )"/>
+
+ </concrete-aspect>
+ </aspects>
+</aspectj>
--- /dev/null
+<aspectj>
+ <weaver options="-Xnoinline"/>
+ <aspects>
+ <concrete-aspect name="AA"
+ extends="A">
+
+ <pointcut name="p" expression="within(C) AND call(* foo(..))" />
+
+ </concrete-aspect>
+ </aspects>
+</aspectj>
</run>
</ajc-test>
+ <ajc-test dir="bugs152/pr135865" title="misbehaving declare annotation">
+ <compile files="B.java,A.java" options="-1.5">
+ <!--message kind="weave" text="Join point 'method-call(void B.foo())' in Type 'A' (A.java:32) advised by before advice from 'Aspect' (A.java:22) [with runtime test]"/>
+ <message kind="weave" text="Join point 'method-call(void A.foo())' in Type 'A' (A.java:33) advised by before advice from 'Aspect' (A.java:22) [with runtime test]"/>
+ <message kind="weave" text="' void B.goo()' (A.java:7) is annotated with @Ann method annotation from 'Aspect' (A.java:27)"/-->
+ </compile>
+ <run class="A">
+ <stdout>
+ <line text="Join point: call(void B.foo())"/>
+ <line text="Join point: call(void B.goo())"/>
+ </stdout>
+ </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">
</compile>
</ajc-test>
+ <ajc-test dir="bugs152/pr142165" title="broken concretization">
+ <compile files="C.java" options="-1.5"/>
+ <compile files="A.java" options="-1.5"/>
+ <run class="C" ltw="aop.xml">
+ <stderr>
+ <line text="warning at Type 'AA' (no debug info available)::0 no match for this type name: SomeType [Xlint:invalidAbsoluteTypeName]"/>
+ <line text="foo running"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="bugs152/pr142165" title="broken concretization - 2">
+ <compile files="C.java" options="-1.5"/>
+ <compile files="A.java" options="-1.5"/>
+ <run class="C" ltw="aop2.xml">
+ <stderr>
+ <line text="foo running"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="bugs152/pr142165" title="broken concretization - 3">
+ <compile files="C.java" options="-1.5"/>
+ <compile files="A.java" options="-1.5"/>
+ <run class="C" ltw="aop3.xml">
+ <stderr>
+ <line text="advice"/>
+ <line text="foo running"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
</suite>
\ No newline at end of file