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.

SynchronizedMethodsOnInterfaces.java 905B

12345678910111213141516171819202122232425262728293031323334353637
  1. import org.aspectj.testing.*;
  2. import java.lang.reflect.*;
  3. public class SynchronizedMethodsOnInterfaces {
  4. public static void main(String[] args) {
  5. new SynchronizedMethodsOnInterfaces().realMain(args);
  6. }
  7. static {
  8. Tester.expectEventsInString("I,C");
  9. }
  10. public void realMain(String[] args) {
  11. method(new D());
  12. method(new C());
  13. Tester.checkAllEvents();
  14. }
  15. void method(Object o) {
  16. try {
  17. o.getClass().getMethod("method", new Class[]{}).invoke(o, new Object[]{});
  18. } catch (Throwable t) {
  19. Tester.check(false, t+"");
  20. }
  21. }
  22. public SynchronizedMethodsOnInterfaces() {
  23. }
  24. }
  25. interface I {}
  26. class D implements I {}
  27. class C {}
  28. aspect AspectI {
  29. public synchronized void I.method() { Tester.event("I"); }
  30. }
  31. aspect AspectC {
  32. public synchronized void C.method() { Tester.event("C"); }
  33. }