blob: 6c4b66f471b3e4a7a95ea19a9ff8e8f809a495a8 (
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
import org.aspectj.testing.Tester;
import org.aspectj.testing.Tester;
public class IntroduceInnerInterfaceCP {
public static void main(String[] args) {
new TargetClass().walk();
new TargetClassWithoutImplementation().run();
AnotherClass.invoke();
Tester.checkAllEvents();
}
private static final String[] EXPECTED;
static {
EXPECTED = new String[]
{ "walk", "Implementation.walk",
"execution(void TargetClass.walk())",
"AnotherClass.invoke()",
"Protected execution(void AnotherClass.invoke())"
};
Tester.expectEventsInString(EXPECTED);
}
}
class Signal {
public static final void signal(String s) {
//System.err.println(s);
Tester.event(s);
}
}
class TargetClass {
public void walk() {
Signal.signal("walk");
}
}
class TargetClassWithoutImplementation {
void run() { }
}
aspect Aspect {
/** @testcase PR#494 adding private interface inside aspect */
private interface Inner {
// automagically interpreted as public
void walk();
}
/** @testcase PR#494 using private interface inside aspect for introductions */
declare parents
: TargetClass implements Inner;
declare parents
: TargetClassWithoutImplementation implements Inner;
declare parents
: TargetClassWithoutImplementation extends Implementation;
static class Implementation {
public void walk() {
Signal.signal("Implementation.walk");
}
}
/** @testcase PR#494 using private interface inside aspect in advice */
before(TargetClassWithoutImplementation t) : target(t)
&& execution(void TargetClassWithoutImplementation.run()) {
((Inner) t).walk();
}
/** @testcase PR#494 using private interface inside aspect in execution pcd */
before() : execution(public void Inner.*()) {
// validate that interface implemented - addressable in pcd
Signal.signal(thisJoinPointStaticPart.toString());
}
}
class AnotherClass {
static void invoke() {
Signal.signal("AnotherClass.invoke()");
}
}
abstract aspect AbstractAspect {
/** Protected has no join points - validate with ShowToChild before advice */
protected interface Protected {}
}
aspect ShowToChild extends AbstractAspect {
/** @testcase PR#494 compile should bind protected interface name in aspect subclass for introduction */
declare parents : AnotherClass implements Protected;
/** @testcase PR#494 compile should bind protected interface name in aspect subclass for advice (even when binding static, non-interface methods with tag interfaces) */
after () : within(Protected+) && execution(* *(..)) {
Signal.signal("Protected " + thisJoinPointStaticPart.toString());
}
/** Protected has no join points */
before () : within(Protected) {
Tester.checkFailed("within Protected");
}
}
|