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.

FieldInnerAccess.java 1012B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import org.aspectj.testing.Tester;
  2. public class FieldInnerAccess {
  3. public static void main(String[] args) {
  4. Derived d = new Derived();
  5. d.m();
  6. Tester.checkAndClearEvents(new String[] {"lock: 1"});
  7. d.mi();
  8. Tester.checkAndClearEvents(new String[] {"lock: 1"});
  9. d.mib();
  10. Tester.checkAndClearEvents(new String[] {"lock: foo"});
  11. }
  12. }
  13. class Base {
  14. private static String lock = "foo";
  15. public void mib() {
  16. Runnable r = new Runnable() {
  17. public void run() {
  18. Tester.event("lock: " + lock);
  19. }
  20. };
  21. r.run();
  22. }
  23. }
  24. class Derived extends Base {
  25. private static Object lock = new Integer(1);
  26. public void m() {
  27. Tester.event("lock: " + lock);
  28. }
  29. public void mi() {
  30. Runnable r = new Runnable() {
  31. public void run() {
  32. Tester.event("lock: " + lock);
  33. }
  34. };
  35. r.run();
  36. }
  37. }