blob: f37ac8b371dff338727e16cba114fbbf0058583d (
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
import org.aspectj.testing.Tester;
class C implements Runnable { // CW 5
public void run() {
}
}
class F implements Runnable {
F(int i) {}// CW 10
public void run() {
}
}
/** @testcase PR#49295 extra warning (join point?) for typepattern-type execution */
public class SubtypeConstructorCW {
public static void main(String[] args) {
new C().run();
new D("").run();
new E("", 0).run();
new F(0).run();
}
}
class D implements Runnable {
D(String s) {
}
public void run() {
}
}
class E implements Runnable {
E(String s, int i) {
}
public void run() {
}
}
// XXX warning: harness might ignore duplicates, so this can give false positives
aspect A {
static {
Tester.expectEvents(
new String[] {
"before execution(C())",
"before execution(F(int))",
});
}
static void event(String s) {
System.out.println(" \"" + s + "\",");
}
// getting two warning rather than one, and on wrong places
declare warning : execution((Runnable +).new (..))
&& !execution(new (String,
.
.)) : "Runnable constructors should take String as first parameter";
// this works as expected
// declare warning: execution((!Runnable && Runnable+).new(..))
// && !execution(new(String, ..))
// : "Runnable constructors should take String as first parm";
before() : execution((Runnable +).new (..))
&& !execution(new (String,..)) {
event("before " + thisJoinPointStaticPart);
}
}
|