aboutsummaryrefslogtreecommitdiffstats
path: root/tests/features164/declareMixin/CaseR.java
blob: dc12baa4eac5da0e3ddd40286f9b5a8ec635bc06 (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
// TESTING: interface subsetting used (factory returns class) - but only one method should be delegated
import org.aspectj.lang.annotation.*;

public class CaseP {
  public static void main(String[]argv) { 
    ((I)new CaseP()).foo();
    CaseP cp = new CaseP();
    if (cp instanceof J) { // should not have been mixed in
      throw new RuntimeException();
    }
  }
}

aspect X {
  @DeclareMixin(value="CaseP",interfaces={I.class})
  public static C createImplementation1() {return new C();}

}

interface I {
  void foo();
}

interface J {
  void goo();
}

class C implements I,J {
  public void foo() {
    System.out.println("foo() running");
  }
  public void goo() {
    System.out.println("goo() running");
  }
}