blob: 4fd0e66eba5029e966c5b20e83071067c90205bb (
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
|
public class PrivilegedParsing {
private int hidden;
public int visible;
public PrivilegedParsing(int priv, int pub) {
hidden = priv;
visible = pub;
}
public void doSomething() {
System.out.println("" + hidden + ", " + visible + "");
}
public static void main(String[] args) {
PrivilegedParsing capsule = new PrivilegedParsing(1, 1);
capsule.doSomething();
}
}
aspect Outer {
static privileged //<== JUST TRY TO UNCOMMENT THIS!
aspect Inner {
pointcut call2doSomething(PrivilegedParsing capsule):
call(void PrivilegedParsing.doSomething())
&& target(capsule);
before(PrivilegedParsing capsule): call2doSomething(capsule) {
capsule.visible++;
capsule.hidden++;
}
}
}
interface Marker {
static privileged //<== JUST TRY TO UNCOMMENT THIS!
aspect Inner {
pointcut call2doSomething(PrivilegedParsing capsule):
call(void PrivilegedParsing.doSomething())
&& target(capsule);
before(PrivilegedParsing capsule): call2doSomething(capsule) {
capsule.visible++;
capsule.hidden++;
}
}
}
|