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.

PrivateIntro.java 700B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import org.aspectj.testing.Tester;
  2. public class PrivateIntro {
  3. public static void test() {
  4. Tester.checkEqual(new A1().getWhere(), "A1", "from A1");
  5. Tester.checkEqual(new A2().getWhere(), "A2", "from A2");
  6. }
  7. public static void main(String[] args) {
  8. test();
  9. }
  10. }
  11. class A1 {
  12. private introduction Foo {
  13. String fromWhere() {
  14. return "A1";
  15. }
  16. }
  17. public String getWhere() {
  18. return new Foo().fromWhere();
  19. }
  20. }
  21. class A2 {
  22. private introduction Foo {
  23. String fromWhere() {
  24. return "A2";
  25. }
  26. }
  27. public String getWhere() {
  28. return new Foo().fromWhere();
  29. }
  30. }
  31. class Foo {}