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.

AfterReturningInterfaceConstructor.java 711B

123456789101112131415161718192021222324252627282930313233
  1. import org.aspectj.testing.Tester;
  2. /** @testcase PR#889 after returning advice on interface constructor */
  3. public class AfterReturningInterfaceConstructor {
  4. public static void main (String[] args) {
  5. Tester.expectEvent("constructor");
  6. Tester.expectEvent("advice");
  7. I i = new C();
  8. Tester.checkEqual(i.i, 2, "i.i");
  9. Tester.checkAllEvents();
  10. }
  11. }
  12. interface I {}
  13. class C implements I {
  14. C() {
  15. Tester.event("constructor");
  16. }
  17. }
  18. aspect A {
  19. int I.i;
  20. after(I i) returning: this(i) && initialization(I.new(..)) {
  21. i.i = 2;
  22. }
  23. after() returning: initialization(I.new(..)) {
  24. Tester.event("advice");
  25. }
  26. }