--- /dev/null
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @interface Color { String value();}
+
+@Color("red")
+public class AnnotatedType {
+ public static void main(String[] argv) {
+ new AnnotatedType().m();
+ }
+
+ public void m() {
+ System.err.println("m() running");
+ }
+}
--- /dev/null
+public class BaseTypes {
+
+ public static void main(String []argv) {
+ new A().m();
+ new B().m();
+ new C().m();
+ }
+
+}
+
+class A {
+ public void m() { System.err.println("A.m() running");}
+}
+
+class B extends A{
+}
+
+class C extends B{
+}
--- /dev/null
+public class BaseTypes {
+
+ public static void main(String []argv) {
+ new A().m();
+ new B().m();
+ new C().m();
+ }
+
+}
+
+class A {
+ public void m() { System.err.println("A.m() running");}
+}
+
+class B extends A{
+}
+
+class C extends B{
+}
--- /dev/null
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) public @interface Colored {String value();}
--- /dev/null
+package p.q;
+import java.lang.annotation.*;
+
+
+@Retention(RetentionPolicy.RUNTIME) @interface Colored {String value();}
+@Retention(RetentionPolicy.RUNTIME) @interface Fruit {String value();}
+@Retention(RetentionPolicy.RUNTIME) @interface Material {String value();}
+
+aspect AllTogether {
+
+ declare @type: DeathByAnnotations: @Colored("red");
+ declare @method: * m*(..): @Fruit("tomato");
+ declare @constructor: DeathByAnnotations.new(..): @Fruit("tomato");
+
+ declare @field: * DeathByAnnotations.*: @Material("wood");
+
+}
+
+public class DeathByAnnotations {
+ int i;
+ static String s;
+
+ public static void main(String[]argv) {
+ new DeathByAnnotations().i = 3;
+ s = "hello";
+ new DeathByAnnotations().m1();
+ new DeathByAnnotations(3).m2();
+ }
+
+ public DeathByAnnotations() {}
+ public DeathByAnnotations(int i) {}
+
+ public void m1() {}
+ public void m2() {}
+
+}
--- /dev/null
+import java.lang.annotation.*;
+
+interface Marker {}
+
+@Retention(RetentionPolicy.RUNTIME) @interface Color { String value();}
+
+// Color put on a particular type, marker interface added to any types with Color annotation
+// Deca specified first
+public aspect DecaDecpInteractions1 {
+
+ declare @type: A : @Color("red");
+
+ declare parents: @Color * implements Marker;
+}
+
+aspect X {
+ before(): execution(* *(..)) && this(Marker) {
+ System.err.println("Marker interface identified on "+thisJoinPoint);
+ }
+ before(): execution(* *(..)) && @this(Color) {
+ System.err.println("Color annotation identified on "+thisJoinPoint);
+ }
+}
--- /dev/null
+import java.lang.annotation.*;
+
+interface Marker {}
+
+@Retention(RetentionPolicy.RUNTIME) @interface Color { String value();}
+
+// Color put on a particular type, marker interface added to any types with Color annotation
+// Decp specified first
+public aspect DecaDecpInteractions2 {
+
+ declare parents: @Color * implements Marker;
+
+ declare @type: A : @Color("red");
+}
+
+aspect X {
+ before(): execution(* *(..)) && this(Marker) {
+ System.err.println("Marker interface identified on "+thisJoinPoint);
+ }
+ before(): execution(* *(..)) && @this(Color) {
+ System.err.println("Color annotation identified on "+thisJoinPoint);
+ }
+}
--- /dev/null
+import java.lang.annotation.*;
+
+interface Marker {}
+
+@Retention(RetentionPolicy.RUNTIME) @interface Color { String value();}
+
+// Put the marker interface on a particular type and add the annotation on
+// types with that interface.
+// deca specified first
+public aspect DecaDecpInteractions3 {
+
+ declare @type: Marker+ : @Color("red");
+
+ declare parents: A* implements Marker;
+}
+
+aspect X {
+ before(): execution(* *(..)) && this(Marker) {
+ System.err.println("Marker interface identified on "+thisJoinPoint);
+ }
+ before(): execution(* *(..)) && @this(Color) {
+ System.err.println("Color annotation identified on "+thisJoinPoint);
+ }
+}
--- /dev/null
+import java.lang.annotation.*;
+
+interface Marker {}
+
+@Retention(RetentionPolicy.RUNTIME) @interface Color { String value();}
+
+// Put the marker interface on a particular type and add the annotation on
+// types with that interface.
+// decp specified first
+public aspect DecaDecpInteractions4 {
+
+ declare parents: A* implements Marker;
+
+ declare @type: Marker+ : @Color("red");
+}
+
+aspect X {
+ before(): execution(* *(..)) && this(Marker) {
+ System.err.println("Marker interface identified on "+thisJoinPoint);
+ }
+ before(): execution(* *(..)) && @this(Color) {
+ System.err.println("Color annotation identified on "+thisJoinPoint);
+ }
+}
--- /dev/null
+import java.lang.annotation.*;
+
+public class DecaType1 {
+ public static void main(String[] argv) {
+ Annotation a = DecaType1.class.getAnnotation(MyAnnotation.class);
+ System.err.println("annotation is "+a);
+ }
+}
+
+aspect X {
+ declare @type: DecaType1 : @MyAnnotation;
+}
+
+@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
+@interface MyAnnotation {}
--- /dev/null
+import java.lang.annotation.*;
+
+public class DecaType2 {
+ public static void main(String[] argv) {
+ Annotation a = DecaType2.class.getAnnotation(MyAnnotation.class);
+ System.err.println("annotation on DecaType2 is "+a);
+ a = X.class.getAnnotation(MyAnnotation.class);
+ System.err.println("annotation on X is "+a);
+ a = MyAnnotation.class.getAnnotation(MyAnnotation.class);
+ System.err.println("annotation on MyAnnotation is "+a);
+ }
+}
+
+aspect X {
+ declare @type: * : @MyAnnotation;
+}
+
+@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
+@interface MyAnnotation {}
+
--- /dev/null
+import java.lang.annotation.*;
+
+public class DecaType3 {
+ public static void main(String[] argv) {
+ new DecaType3().sayhello();
+ }
+ public void sayhello() {
+ System.err.println("hello world");
+ }
+}
+
+aspect X {
+ declare @type: DecaType3 : @MyAnnotation;
+
+ after(): call(* println(..)) && @this(MyAnnotation) {
+ System.err.println("advice running");
+ }
+}
+
+@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
+@interface MyAnnotation {}
--- /dev/null
+
+public aspect DecaTypeBin1 {
+ declare @type: A : @Colored("red");
+}
+
+aspect X {
+ before(): execution(* *(..)) && @this(Colored) {
+ System.err.println("Color identified on "+this.getClass());
+ }
+}
--- /dev/null
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @interface ComplexAnnotation {
+ int ival();
+ byte bval();
+ char cval();
+ long jval();
+ double dval();
+ boolean zval();
+ short sval();
+ float fval();
+ String s();
+}
+
+public aspect DecaTypeBin2 {
+ declare @type: A : @ComplexAnnotation(ival=4,bval=2,cval=5,fval=3.0f,dval=33.4,zval=false,jval=56,sval=99,s="s");
+}
+
+aspect X {
+ before(): execution(* *(..)) && @this(ComplexAnnotation) {
+ System.err.println("ComplexAnnotation identified on "+thisJoinPoint);
+ }
+}
--- /dev/null
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @interface Color { String value();}
+@Retention(RetentionPolicy.RUNTIME) @interface Fruit { String value();}
+
+public aspect DecaTypeBin3 {
+ declare @type: A : @Color("Yellow");
+ declare @type: A : @Fruit("Banana");
+}
+
+aspect X {
+ before(): execution(* *(..)) && @this(Color) {
+ System.err.println("Color identified on "+thisJoinPoint);
+ }
+
+ before(): execution(* *(..)) && @this(Fruit) {
+ System.err.println("Fruit identified on "+thisJoinPoint);
+ }
+}
--- /dev/null
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @interface Fruit { String value();}
+
+public aspect DecaTypeBin4 {
+ declare @type: AnnotatedType : @Fruit("Banana");
+}
+
+aspect X {
+ before(): execution(* *(..)) && @this(Color) {
+ System.err.println("Color identified on "+thisJoinPoint);
+ }
+
+ before(): execution(* *(..)) && @this(Fruit) {
+ System.err.println("Fruit identified on "+thisJoinPoint);
+ }
+}
--- /dev/null
+// Putting the wrong annotations onto types
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @interface ColorT { String value();}
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @interface ColorM { String value();}
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.CONSTRUCTOR) @interface ColorC { String value();}
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.ANNOTATION_TYPE) @interface ColorA { String value();}
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) @interface ColorF { String value();}
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.PARAMETER) @interface ColorP { String value();}
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.LOCAL_VARIABLE) @interface ColorL { String value();}
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.PACKAGE) @interface ColorPkg { String value();}
+
+public aspect DecaTypeBin5 {
+ declare @type: A : @ColorT("Red");
+ declare @type: A : @ColorM("Orange");
+ declare @type: A : @ColorC("Yellow");
+ declare @type: A : @ColorA("Green");
+ declare @type: A : @ColorF("Blue");
+ declare @type: A : @ColorP("Indigo");
+ declare @type: A : @ColorL("Violet");
+ declare @type: A : @ColorPkg("White");
+}
+
+aspect X {
+ before(): execution(* *(..)) && @this(ColorT) { System.err.println("ColorT identified on "+thisJoinPoint); }
+ before(): execution(* *(..)) && @this(ColorM) { System.err.println("ColorM identified on "+thisJoinPoint); }
+ before(): execution(* *(..)) && @this(ColorC) { System.err.println("ColorC identified on "+thisJoinPoint); }
+ before(): execution(* *(..)) && @this(ColorA) { System.err.println("ColorA identified on "+thisJoinPoint); }
+ before(): execution(* *(..)) && @this(ColorF) { System.err.println("ColorF identified on "+thisJoinPoint); }
+ before(): execution(* *(..)) && @this(ColorP) { System.err.println("ColorP identified on "+thisJoinPoint); }
+ before(): execution(* *(..)) && @this(ColorL) { System.err.println("ColorL identified on "+thisJoinPoint); }
+ before(): execution(* *(..)) && @this(ColorPkg) { System.err.println("ColorPkg identified on "+thisJoinPoint); }
+
+}
--- /dev/null
+// Putting the wrong annotations on types but specifying patterns as the target
+// rather than exact types
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @interface ColorT { String value();}
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @interface ColorM { String value();}
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.CONSTRUCTOR) @interface ColorC { String value();}
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) @interface ColorF { String value();}
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.PARAMETER) @interface ColorP { String value();}
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.LOCAL_VARIABLE) @interface ColorL { String value();}
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.PACKAGE) @interface ColorPkg { String value();}
+
+public aspect DecaTypeBin6 {
+ declare @type: A+ : @ColorT("Red");
+ declare @type: A* : @ColorM("Orange");
+ declare @type: *A : @ColorC("Yellow");
+ declare @type: *A+ : @ColorL("Green");
+ declare @type: @ColorT * : @ColorF("Blue"); // also checks we loop correctly...
+}
+
+aspect X {
+ before(): execution(* *(..)) && @this(ColorT) { System.err.println("ColorT identified on "+thisJoinPoint); }
+ before(): execution(* *(..)) && @this(ColorM) { System.err.println("ColorM identified on "+thisJoinPoint); }
+ before(): execution(* *(..)) && @this(ColorC) { System.err.println("ColorC identified on "+thisJoinPoint); }
+ before(): execution(* *(..)) && @this(ColorF) { System.err.println("ColorF identified on "+thisJoinPoint); }
+ before(): execution(* *(..)) && @this(ColorP) { System.err.println("ColorP identified on "+thisJoinPoint); }
+ before(): execution(* *(..)) && @this(ColorL) { System.err.println("ColorL identified on "+thisJoinPoint); }
+ before(): execution(* *(..)) && @this(ColorPkg) { System.err.println("ColorPkg identified on "+thisJoinPoint); }
+
+}
--- /dev/null
+// Putting the wrong annotations on types but specifying patterns as the target
+// rather than exact types
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @interface Color { String value();}
+@Retention(RetentionPolicy.RUNTIME) @interface Fruit { String value();}
+@Retention(RetentionPolicy.RUNTIME) @interface Chocolate { String value();}
+
+interface M1 {}
+interface M2 {}
+interface M3 {}
+
+// sick and twisted
+public aspect DecaTypeBin7 {
+ declare parents: @Chocolate * implements M3;
+ declare @type: A : @Color("Red");
+ declare @type: M1+ : @Fruit("Banana");
+ declare parents: @Color * implements M1;
+ declare @type: M2+ : @Chocolate("maltesers");
+ declare parents: @Fruit * implements M2;
+
+ public void B.m() { System.err.println("B.m() running"); }
+ public void C.m() { System.err.println("C.m() running"); }
+}
+
+aspect X {
+ before(): execution(* *(..)) && @this(Color) { System.err.println("Color identified on "+thisJoinPoint); }
+ before(): execution(* *(..)) && @this(Fruit) { System.err.println("Fruit identified on "+thisJoinPoint); }
+ before(): execution(* *(..)) && @this(Chocolate) { System.err.println("Chocolate identified on "+thisJoinPoint); }
+ before(): execution(* *(..)) && target(M1) { System.err.println("M1 at "+thisJoinPoint); }
+ before(): execution(* *(..)) && target(M2) { System.err.println("M2 at "+thisJoinPoint); }
+ before(): execution(* *(..)) && target(M3) { System.err.println("M3 at "+thisJoinPoint); }
+
+}
--- /dev/null
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @interface ColorT { String value();}
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.ANNOTATION_TYPE) @interface ColorA { String value();}
+
+public aspect DecaTypeBin8 {
+ declare @type: A : @ColorT("Red");
+ declare @type: A : @ColorA("Green");
+}
+
--- /dev/null
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @interface ColorT { String value();}
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.ANNOTATION_TYPE) @interface ColorA { String value();}
+
+public aspect DecaTypeBin9 {
+ declare @type: A* : @ColorT("Red");
+ declare @type: A* : @ColorA("Green");
+}
+
--- /dev/null
+import java.lang.annotation.*;
+
+enum SimpleEnum { Red,Orange,Yellow,Green,Blue,Indigo,Violet };
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface AnnotationEnumElement {
+ SimpleEnum enumval();
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface AnnotationClassElement {
+ Class clz();
+}
+
+
+aspect AnnotatedWithEnumClass {
+ declare @type: FunkyAnnotations : @AnnotationEnumElement(enumval=SimpleEnum.Red);
+ declare @type: FunkyAnnotations : @AnnotationClassElement(clz=Integer.class);
+
+ before(AnnotationEnumElement aee): call(* *(..)) && @target(aee) {
+ System.err.println("advice running: "+aee.enumval());
+ }
+
+ before(AnnotationClassElement ace): call(* *(..)) && @target(ace) {
+ System.err.println("advice running: "+ace.clz());
+ }
+}
--- /dev/null
+public class FunkyAnnotations {
+
+ public static void main(String[] argv) {
+ new FunkyAnnotations().m();
+ }
+ public void m() {
+ System.err.println("method running");
+ }
+}
--- /dev/null
+import java.lang.annotation.*;
+
+enum SimpleEnum { Red,Orange,Yellow,Green,Blue,Indigo,Violet };
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface AnnotationEnumElement {
+ SimpleEnum enumval();
+}
+
+
+@AnnotationEnumElement(enumval=SimpleEnum.Red)
+class C {
+}
--- /dev/null
+//Simple declare annotation attached to a field
+public aspect AtField1 {
+ declare @field: public int * : @Colored("red");
+ declare parents: AtField1 implements java.io.Serializable;
+}
+
+aspect X {
+ before(): set(@Colored * *) {
+ System.err.println("Colored field access at "+thisJoinPoint);
+ }
+}
--- /dev/null
+import java.util.*;
+
+public class Base {
+
+ public int publicIntField;
+
+ private String privateStringField;
+
+ public List publicListField;
+
+ protected List protectedListField;
+
+ public static void main(String[]argv) {
+ new Base().x();
+ }
+
+ public void x() {
+ publicIntField = 1;
+ privateStringField = "aaa";
+ publicListField = new ArrayList();
+ protectedListField = new ArrayList();
+ }
+}
--- /dev/null
+import java.lang.annotation.*;
+@Retention(RetentionPolicy.RUNTIME) public @interface Colored {String value();}
--- /dev/null
+import java.lang.annotation.*;
+@Retention(RetentionPolicy.RUNTIME) public @interface Fruit {String value();}
--- /dev/null
+// check order of application - this should work
+public aspect RecursiveFields {
+ declare @field: public int * : @Colored("blue");
+ declare @field: @Colored * * : @Fruit("orange");
+}
+
+aspect X {
+ before(): set(@Fruit * *) {
+ System.err.println("Fruit field access at "+thisJoinPoint);
+ }
+}
--- /dev/null
+// check order of application - this should work
+public aspect RecursiveFields2 {
+ declare @field: @Colored * * : @Fruit("orange");
+ declare @field: public int * : @Colored("blue");
+}
+
+aspect X {
+ before(): set(@Fruit * *) {
+ System.err.println("Fruit field access at "+thisJoinPoint);
+ }
+}
--- /dev/null
+// trying to put annotations on that correctly use @Target
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) @interface FieldColoring { String value(); }
+
+public aspect RightTarget {
+ declare @field: public int * : @FieldColoring("red");
+}
+
+aspect X {
+ before(): set(@FieldColoring * *) {
+ System.err.println("Colored field access at "+thisJoinPoint);
+ }
+}
--- /dev/null
+// trying to put two annotations onto one field
+public aspect TwoOnOneField {
+ declare @field: public int * : @Colored("red");
+ declare @field: public int * : @Colored("blue");
+}
+
+aspect X {
+ before(): set(@Colored * *) {
+ System.err.println("Colored field access at "+thisJoinPoint);
+ }
+}
--- /dev/null
+// trying to put two annotations onto one field - should be OK, they are diff annotations
+public aspect TwoOnOneField2 {
+ declare @field: public int * : @Colored("yellow");
+ declare @field: public int * : @Fruit("banana");
+}
+
+aspect X {
+ before(): set(@Colored * *) {
+ System.err.println("Colored field access at "+thisJoinPoint);
+ }
+ before(): set(@Fruit * *) {
+ System.err.println("Fruit field access at "+thisJoinPoint);
+ }
+}
--- /dev/null
+// trying to put wrong annotations onto a field
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @interface MethodColoring { String value(); }
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @interface TypeColoring { String value(); }
+
+public aspect WrongTarget {
+ declare @field: public int * : @MethodColoring("red");
+ declare @field: public int * : @TypeColoring("blue");
+}
+
+aspect X {
+ before(): set(@MethodColoring * *) {
+ System.err.println("Colored field access at "+thisJoinPoint);
+ }
+ before(): set(@TypeColoring * *) {
+ System.err.println("Colored field access at "+thisJoinPoint);
+ }
+}
--- /dev/null
+typeNotExposedToWeaver=ignore
+adviceDidNotMatch=ignore
--- /dev/null
+
+public aspect AtCtor1 {
+ declare @constructor: new(int) : @Colored("red");
+}
+
+aspect X {
+ before(): call(new(..)) && @annotation(Colored) {
+ System.err.println("Colored constructor invocation at "+thisJoinPoint);
+ }
+}
--- /dev/null
+
+public aspect AtMethod1 {
+ declare @method: void m1(..) : @Colored("red");
+
+}
+
+aspect X {
+ before(Colored c): call(* *(..)) && @annotation(c) {
+ System.err.println("Colored method invocation at "+thisJoinPoint);
+ }
+}
--- /dev/null
+import java.util.*;
+
+public class Base {
+
+ public void m1() { System.err.println("m1() running");}
+ protected void m2() { System.err.println("m2() running");}
+ public static void m3() { System.err.println("m3() running");}
+
+ public static void main(String[]argv) {
+ // new Base().x();
+ new Base(3).x();
+ }
+
+ public void x() {
+ m1();
+ m2();
+ m3();
+ }
+
+ public Base() {}
+
+ public Base(int i) {}
+
+}
--- /dev/null
+import java.lang.annotation.*;
+@Retention(RetentionPolicy.RUNTIME) public @interface Colored {String value();}
--- /dev/null
+import java.lang.annotation.*;
+@Retention(RetentionPolicy.RUNTIME) public @interface Fruit {String value();}
--- /dev/null
+// trying to put annotations on that correctly use @Target
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @interface MethodColoring { String value(); }
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.CONSTRUCTOR) @interface CtorColoring { String value(); }
+
+public aspect RightTarget {
+ declare @method: public void m1(..) : @MethodColoring("red");
+ declare @constructor: public new(int) : @CtorColoring("red");
+}
+
+aspect X {
+ before(): call(* *(..)) && @annotation(MethodColoring) {
+ System.err.println("Colored method call at "+thisJoinPoint);
+ }
+ before(): call(new(..)) && @annotation(CtorColoring) {
+ System.err.println("Colored ctor call at "+thisJoinPoint);
+ }
+}
--- /dev/null
+// trying to put two annotations onto one method and two on one ctor - should both be errors
+public aspect TwoOnOneMember {
+ declare @method: public void m1() : @Colored("red");
+ declare @method: public void m1() : @Colored("blue");
+ declare @constructor: new(int) : @Colored("red");
+ declare @constructor: new(int) : @Colored("blue");
+}
+
--- /dev/null
+// trying to put two annotations onto one a method and two on a ctor
+// - should be OK, they are diff annotations
+public aspect TwoOnOneMember2 {
+ declare @method: public void m1() : @Colored("red");
+ declare @method: public void m1() : @Fruit("tomato");
+ declare @constructor: new(int) : @Colored("green");
+ declare @constructor: new(int) : @Fruit("apple");
+}
+
+aspect X {
+ before(): call(* *(..)) && @annotation(Colored) {
+ System.err.println("Colored method call at "+thisJoinPoint.getSourceLocation());
+ }
+ before(): call(* *(..)) && @annotation(Fruit) {
+ System.err.println("Fruit method call at "+thisJoinPoint.getSourceLocation());
+ }
+ before(): call(new(..)) && @annotation(Colored) {
+ System.err.println("Colored ctor call at "+thisJoinPoint.getSourceLocation());
+ }
+ before(): call(new(..)) && @annotation(Fruit) {
+ System.err.println("Fruit ctor call at "+thisJoinPoint.getSourceLocation());
+ }
+}
--- /dev/null
+// trying to put wrong annotations onto a field
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) @interface MethodColoring { String value(); }
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @interface TypeColoring { String value(); }
+
+public aspect WrongTarget {
+ declare @method: void m1(..) : @MethodColoring("red");
+ declare @method: void m1(..) : @TypeColoring("blue");
+ declare @constructor: new(..) : @MethodColoring("red");
+ declare @constructor: new(..) : @TypeColoring("blue");
+}
+
--- /dev/null
+typeNotExposedToWeaver=ignore
+adviceDidNotMatch=ignore
--- /dev/null
+typeNotExposedToWeaver=ignore
+adviceDidNotMatch=ignore