summaryrefslogtreecommitdiffstats
path: root/tests/features164/declareMixin/CaseF.java
blob: 8e4fd502549b43b4a7b8bcb39f4125ed7df5cab9 (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
// TESTING: Factory method directly takes the type specified in the Mixin target (strongly typed)
import org.aspectj.lang.annotation.*;

public class CaseF {
  public static void main(String[]argv) {
    CaseF cc = new CaseF();
    ((I)cc).methodOne(); // will only succeed if mixin applied
  }

  public String toString() {
    return "CaseF instance";
  }
}

aspect X {
  @DeclareMixin("CaseF")
  public static I createImplementation(CaseF cf) {
    System.out.println("Delegate factory invoked for "+cf.toString());
    return new Implementation(cf);
  }
}

interface I {
  void methodOne();
}

class Implementation implements I {
  public Implementation(CaseF cf) {}
  public void methodOne() {
    System.out.println("methodOne running");
  }
}