mirror of
https://github.com/eclipse-aspectj/aspectj.git
synced 2024-08-18 14:13:31 +02:00
33 lines
801 B
Java
33 lines
801 B
Java
![]() |
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;
|
||
|
}
|
||
|
}
|