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.

SupersAndInterfaces.java 879B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import org.aspectj.testing.Tester;
  2. import java.io.IOException;
  3. public class SupersAndInterfaces {
  4. public static void main(String[] args) throws IOException {
  5. new C2().m();
  6. Tester.check("ran before");
  7. new C().toString();
  8. Tester.check("ran before toString");
  9. }
  10. }
  11. class C {
  12. public void m() throws IOException {
  13. if (false) throw new IOException("testing");
  14. }
  15. public String toString() {
  16. return super.toString() + "C";
  17. }
  18. }
  19. interface I {
  20. public void m() throws IOException;
  21. }
  22. class C1 extends C implements I {
  23. }
  24. class C2 extends C1 {
  25. static boolean ranBody;
  26. public void m() throws IOException {
  27. ranBody = true;
  28. super.m();
  29. }
  30. }
  31. aspect A {
  32. before(): call(void m()) {
  33. Tester.note("ran before");
  34. Tester.check(!C2.ranBody, "first entry");
  35. }
  36. before(): call(String toString()) {
  37. Tester.note("ran before toString");
  38. }
  39. }