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.

SuperInIntroductionCE.java 981B

1234567891011121314151617181920212223242526272829303132
  1. import org.aspectj.testing.Tester;
  2. public class SuperInIntroductionCE {
  3. public static void main (String[] args) {
  4. int result = new Sub().getInt();
  5. Tester.check(2==result, "new Sub().getInt() !2==" + result);
  6. }
  7. }
  8. class Super {
  9. private int privateInt = 1;
  10. private int privateIntMethod() { return privateInt; }
  11. int defaultedInt = 1;
  12. int defaultIntMethod() { return privateInt; }
  13. }
  14. class Sub extends Super { }
  15. class ObjectSub { }
  16. aspect A {
  17. /** @testcase accessing private and default method and field of class within code the compiler controls */
  18. public int Sub.getInt() {
  19. int result = super.privateInt; // CE 25 expected here
  20. result += super.privateIntMethod(); // CE 26 expected here
  21. // todo: move A and Super to separate packages
  22. //result += defaultInt; // CE expected here
  23. //result += defaultIntMethod(); // CE expected here
  24. return result;
  25. }
  26. }