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.

Main.java 724B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package example;
  2. import org.aspectj.lang.annotation.Aspect;
  3. import org.aspectj.lang.annotation.DeclareParents;
  4. public class Main {
  5. public static void main(String[] args) {
  6. Bar bar = new Bar();
  7. ((Foo)bar).doFoo();
  8. bar.doBar();
  9. }
  10. }
  11. interface Foo {
  12. public void doFoo();
  13. }
  14. class DefaultFoo implements Foo {
  15. // Uncommenting the following fixes the error
  16. // public DefaultFoo() {
  17. // }
  18. public void doFoo() {
  19. System.out.println("In doFoo " + this.getClass());
  20. }
  21. }
  22. class Bar {
  23. public void doBar() {
  24. System.out.println("Bar");
  25. }
  26. }
  27. @Aspect
  28. class Introduce {
  29. @DeclareParents(value="example.Bar", defaultImpl=DefaultFoo.class)
  30. private Foo mixin;
  31. }