Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

CallsAndLocalClasses.java 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import org.aspectj.testing.Tester;
  2. public class CallsAndLocalClasses {
  3. public static void main(String[] args) {
  4. Runnable r = new Outer().makeRunnable();
  5. r.run();
  6. Outer o = new Outer();
  7. o.toString();
  8. ((Comparable)o).toString();
  9. Tester.check("run from Outer");
  10. Tester.check("m");
  11. Tester.check("before run");
  12. Tester.check("before m");
  13. }
  14. }
  15. class Outer implements Comparable {
  16. public int compareTo(Object other) { Tester.note("m"); return 0; }
  17. public Runnable makeRunnable() {
  18. return new Runnable() {
  19. public void run() {
  20. Tester.note("run from Outer");
  21. compareTo(this);
  22. }
  23. };
  24. }
  25. }
  26. final class Foo {
  27. public String toString() { return "Foo"; }
  28. }
  29. aspect A {
  30. before(): call(void Runnable.run()) {
  31. Tester.note("before run");
  32. }
  33. before(): call(int compareTo(Object)) {
  34. Tester.note("before m");
  35. }
  36. before(): call(String Object.toString()) {
  37. System.out.println("before toString");
  38. }
  39. }