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.

InnerSuper.java 735B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import org.aspectj.testing.Tester;
  2. public class InnerSuper {
  3. public static void main(String[] args) {
  4. Counter c = new C().makeCounter();
  5. c.count();
  6. Tester.checkEqual(c.n, 1, "counted");
  7. }
  8. }
  9. class C {
  10. public Counter makeCounter() {
  11. return new Counter() {
  12. public void count() {
  13. n+=1;
  14. }
  15. };
  16. }
  17. public InnerCounter makeInnerCounter() {
  18. class MyCounter extends InnerCounter {
  19. public void count() {
  20. n += 1;
  21. toString();
  22. }
  23. public void lookat(Object o) {
  24. boolean b = o.equals("abc");
  25. }
  26. }
  27. return new MyCounter();
  28. }
  29. protected class InnerCounter {
  30. protected int n;
  31. protected Object o;
  32. }
  33. }
  34. class Counter {
  35. protected int n = 0;
  36. public void count() {}
  37. }