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.

IntroduceInnerInterfaceCF.java 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import org.aspectj.testing.Tester;
  2. import org.aspectj.testing.Tester;
  3. public class IntroduceInnerInterfaceCF {
  4. public static void main(String[] args) {
  5. Tester.checkFailed("!compile");
  6. }
  7. private static final String[] EXPECTED;
  8. static {
  9. EXPECTED = new String[]
  10. { "walk", "execution(void TargetClass.walk())" };
  11. Tester.expectEventsInString(EXPECTED);
  12. }
  13. }
  14. class TargetClass {
  15. /** @testcase PR#494 compile should fail if implementing method is not public */
  16. void defaultMethod() { } // errLine 18
  17. private void privateMethod() { } // errLine 19
  18. protected void protectedMethod() { } // errLine 20
  19. }
  20. class AnotherClass{}
  21. class AThirdClass extends TargetClass implements Aspect.Inner {} // errLine 24
  22. aspect Aspect {
  23. private interface Inner {
  24. // all automagically interpreted as public
  25. void defaultMethod();
  26. void privateMethod();
  27. void protectedMethod();
  28. }
  29. declare parents
  30. : TargetClass implements Inner;
  31. before() : execution(void Inner.*()) {
  32. }
  33. }
  34. aspect PeekingAspect {
  35. after(TargetClass tc) : this(tc) && execution(void TargetClass.walk()) {
  36. /** @testcase PR#494 compile should fail to bind private interface name outside of Aspect */
  37. if (tc instanceof Aspect.Inner) { // errLine 42
  38. Tester.checkFailed("(tc instanceof Aspect.Inner)");
  39. }
  40. if (Aspect.Inner.class.isAssignableFrom(tc.getClass())) { // errLine 45
  41. Tester.checkFailed("(Aspect.Inner.class.isAssignableFrom(tc.getClass())");
  42. }
  43. ((Aspect.Inner) tc).defaultMethod(); // errLine 48
  44. }
  45. declare parents : AnotherClass implements Aspect.Inner; // errLine 50
  46. }
  47. abstract aspect AbstractAspect {
  48. private interface Private {}
  49. }
  50. aspect HideFromChild extends AbstractAspect {
  51. /** @testcase PR#494 compile should fail to bind private interface name in aspect subclass */
  52. declare parents : AnotherClass implements Private; // errLine 58
  53. }
  54. // todo: test cases to validate inner interfaces with package and protected