You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NewVoid.java 801B

123456789101112131415161718192021222324252627282930313233
  1. import org.aspectj.lang.*;
  2. import org.aspectj.lang.reflect.*;
  3. import java.lang.reflect.Method;
  4. public aspect NewVoid {
  5. Object around() :
  6. call(new(..)) {
  7. return proceed();
  8. }
  9. Object around() :
  10. call(* *(..)) {
  11. MethodSignature sig = (MethodSignature)thisJoinPoint.getSignature();
  12. Class returnType = sig.getReturnType();
  13. if (returnType == java.lang.Void.TYPE) {
  14. return new java.lang.Void(); // expect CE here
  15. } else {
  16. String s = "hi";
  17. Xyz xyz = null; // expect CE here
  18. int x = s.count; // expect CE here
  19. return proceed();
  20. }
  21. }
  22. }
  23. privileged aspect PrivCheck {
  24. Object around() : call(* *(..)) {
  25. Xyz xyz = null; // expect CE here
  26. Object o = new Void(); // expect warning here
  27. int x = "goo".count; // expect warning here
  28. return null;
  29. }
  30. }