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.

Driver.java 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // thisResultObject for primitives
  2. // I think this is a bad test. Is there a way to do this? -eh
  3. import org.aspectj.testing.Tester;
  4. public class Driver {
  5. public static void test() {
  6. C1 c1 = new C1();
  7. c1.getInteger();
  8. c1.getDouble();
  9. c1.getVoid();
  10. c1.getString();
  11. c1.getBoolean();
  12. }
  13. public static void main(String[] args) { test(); }
  14. }
  15. class C1 {
  16. int getInteger() {
  17. return 1;
  18. }
  19. double getDouble() {
  20. return 3.14;
  21. }
  22. void getVoid() {
  23. }
  24. String getString() {
  25. return "Hello World";
  26. }
  27. boolean getBoolean() {
  28. return true;
  29. }
  30. }
  31. aspect A1 {
  32. // don't advise the finalize reception, or weird interactions with GC can happen
  33. after() returning (Object result):
  34. target(C1) && call(* *()) && !call(void finalize()) {
  35. if (result == null) {
  36. Tester.checkEqual(thisJoinPoint.getSignature().getName(),
  37. "getVoid",
  38. "void method");
  39. }
  40. else {
  41. String resultClassName = result.getClass().getName();
  42. Tester.checkEqual("java.lang." +
  43. thisJoinPoint.getSignature().getName().substring(3),
  44. resultClassName,
  45. "result object type");
  46. }
  47. }
  48. }