summaryrefslogtreecommitdiffstats
path: root/tests/features164/declareMixin/CaseS.java
blob: aef84923d01af84a2be02b21993db5a4ac73c206 (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
// TESTING: factory method has incompatible return type - verifyerror if we did use that factory
import org.aspectj.lang.annotation.*;

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

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

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

class FooI {
	
}

interface I {
  void methodOne();
}

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