Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ajdt-dev] Parameter annotation matching - now in AJDT.

Following on from my email saying this feature is available in AspectJ
dev builds (see below), it is also now available in the latest AJDT
dev builds for Eclipse 3.3.

Andy.
----


The latest AspectJ dev builds include preliminary support for
parameter annotation matching for constructors and methods.  The use
of parentheses around the parameter types in a method signature
determine whether the annotations relate to the type of the parameter
or the parameter itself.

execution(* *(@A *));
- Execution of a method/ctor whose first parameter is of a type
annotated with @A.

execution(* *(@A (*)));
- Execution of a method/ctor whose first parameter is annotated with @A

execution(* *(@A (@B *)))
- Execution of a method/ctor whose first parameter is annotated with
@A and is of a type annotated with @B.

Example:
------ Start of Test.java -----
@interface A {}
@interface B {}

class C {
  public void foo(@A String s) {}
  public void goo(@A @B String s) {}
}

aspect X {
  before(): execution(* *(@A (*))) {}
  before(): execution(* *(@B (*))) {}
}
------ End of Test.java -----
$ ajc -showWeaveInfo -1.6 Test.java
Join point 'method-execution(void C.foo(java.lang.String))' in Type
'C' (A.java:5) advised by before advice from 'X' (A.java:10)

Join point 'method-execution(void C.goo(java.lang.String))' in Type
'C' (A.java:6) advised by before advice from 'X' (A.java:11)

Join point 'method-execution(void C.goo(java.lang.String))' in Type
'C' (A.java:6) advised by before advice from 'X' (A.java:10)

The first piece of advice matched both methods.  The second only matched goo().

Please try it out.  There is currently no support for binding of
parameter annotations, just static matching.

Andy.


Back to the top