blob: 5ed0292cadef29acc8d0e97fabcdb5b19549b728 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
// proper matching of overloaded constructors
import org.aspectj.testing.Tester;
public aspect Driver {
public static void main(String[] args) { test(); }
after(/*Foo f,*/ String aspectName) returning(Foo f):
/*target(f) &&*/ call(new(String)) && args(aspectName) {
f.name = aspectName+"-ADVISED";
}
public static void test() {
Foo foo = new Foo("NAME");
Tester.checkEqual(foo.name, "NAME-ADVISED", "new Foo(name)");
foo = new Foo();
Tester.checkEqual(foo.name, "NONE", "new Foo()");
}
}
class Foo {
public String name = "NONE";
public Foo() { }
public Foo(String name) {
this.name = name;
}
}
|