aboutsummaryrefslogtreecommitdiffstats
path: root/tests/features164/declareMixin/CaseG.java
blob: fceb7cb7e98be09be71e59817b6cef486348a9c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// TESTING: targeting multiple types from the Mixin
import org.aspectj.lang.annotation.*;

public class CaseG {
  public static void main(String[]argv) {
    ((I)new A()).run();
    ((I)new B()).run();
  }

}

class A {
}
class B {
}

aspect X {
  @DeclareMixin("A || B")
  public I createImplementation(Object o) {
    System.out.println("Delegate factory invoked for instance of "+o.getClass().getSimpleName());
    return new Implementation(o);
  }
}

interface I {
  void run();
}

class Implementation implements I {
  Object o;

  public Implementation(Object o) {
    this.o = o;
  }

  public void run() {
    System.out.println("run() executing on behalf of "+o.getClass().getSimpleName());
  }
}