blob: 0162b5313bb5fddddffef3b163205f8af6f228c9 (
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
|
import org.aspectj.lang.*;
import org.aspectj.lang.reflect.*;
import java.lang.reflect.Method;
public aspect NewVoid {
Object around() :
call(new(..)) {
return proceed();
}
Object around() :
call(* *(..)) {
MethodSignature sig = (MethodSignature)thisJoinPoint.getSignature();
Class returnType = sig.getReturnType();
if (returnType == java.lang.Void.TYPE) {
return new java.lang.Void(); // expect CE here
} else {
String s = "hi";
Xyz xyz = null; // expect CE here
int x = s.count; // expect CE here
return proceed();
}
}
}
privileged aspect PrivCheck {
Object around() : call(* *(..)) {
Xyz xyz = null; // expect CE here
Object o = new Void(); // expect warning here
int x = "goo".count; // expect warning here
return null;
}
}
|