[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] Array type patterns
|
Hello everyone,
I have a question about subtype (+) & array type ([]) patterns (as used in pointcuts).
According to the AspectJ semantics
(http://www.eclipse.org/aspectj/doc/released/progguide/semantics-pointcuts.html#type-patterns) I should be able to
combine both.
For example, if I wanted to capture calls to any public method of path.to.some.Class that
returns an array of Objects, or an array of Object subtypes (eg: String[]), I think I
should be able to use this pointcut:
-----------------------------------------------------------------
pointcut pc() : call(public Object+[] path.to.some.Class.*(..));
-----------------------------------------------------------------
However, statements like this one do not even compile on ajc (using latest released version, both
from commandline and using ajdt in eclipse). I get the following error:
-----------------------------------------------------------------
Syntax error on token "[", "name pattern" expected
-----------------------------------------------------------------
I am rather confident that this should work because on the AspectJ CVS I found
this
(http://dev.eclipse.org/viewcvs/index.cgi/org.aspectj/modules/weaver/testsrc/org/aspectj/weaver/patterns/TypePatternTest
Case.java?root=Tools_Project&view=markup) :
-----------------------------------------------------------------
public void testArrayMatch() {
world = new BcelWorld();
checkMatch("*[][]","java.lang.Object",false);
checkMatch("*[]","java.lang.Object[]",true);
checkMatch("*[][]","java.lang.Object[][]",true);
checkMatch("java.lang.Object[]","java.lang.Object",false);
checkMatch("java.lang.Object[]","java.lang.Object[]",true);
checkMatch("java.lang.Object[][]","java.lang.Object[][]",true);
checkMatch("java.lang.String[]","java.lang.Object",false);
checkMatch("java.lang.String[]","java.lang.Object[]",false);
checkMatch("java.lang.String[][]","java.lang.Object[][]",false);
checkMatch("java.lang.Object+[]","java.lang.String[]",true);
}
-----------------------------------------------------------------
That last chechMatch statement clearly shows that java.lang.Object+[] should
match with java.lang.String[]. Maybe I would, if only my code would compile...
Any ideas anyone?
Thanks a lot in advance!
Regards,
Matthias Stevens