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.

InterfaceMethodDeclarationAbstract.java 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* *******************************************************************
  2. * Copyright (c) 2004 Contributors.
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v 2.0
  6. * which accompanies this distribution and is available at
  7. * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
  8. *
  9. * Contributors:
  10. * Wes Isberg initial implementation
  11. * ******************************************************************/
  12. import org.aspectj.testing.Tester;
  13. /**
  14. * @testcase PR#49784 aspect declares interface method (abstract)
  15. */
  16. public class InterfaceMethodDeclarationAbstract {
  17. public static void main(String[] args) {
  18. Tester.expectEvent("before-execution");
  19. Tester.expectEvent("before-call");
  20. I i = new C();
  21. Tester.check(1 == i.getInt(), "1 == i.getInt()");
  22. Tester.checkAllEvents();
  23. }
  24. }
  25. interface I {}
  26. aspect A {
  27. abstract int I.getInt(); // Error expected: Needs to be public
  28. before() : execution(int getInt()) && target(I) {
  29. Tester.event("before-execution");
  30. }
  31. before() : call(int getInt()) && target(I) {
  32. Tester.event("before-call");
  33. }
  34. }
  35. class C implements I {
  36. public int getInt() { return 1; }
  37. }