aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs150/pr117681/MoodIndicator.java
blob: c6e47e1f3ea62a44b801f9a65d817163b7a2e1e0 (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
40
41
42
import org.aspectj.lang.annotation.*;

class Mood {
  public final static Mood HAPPY=new Mood();
}
   // this interface can be outside of the aspect
    interface Moody {
     Mood getMood(int i);
   };

   // this implementation can be outside of the aspect
    class MoodyImpl implements Moody {
      private Mood mood = Mood.HAPPY;

      public Mood getMood(int i) {
        return mood;
      }
   }
@Aspect
public class MoodIndicator {


   // here is the actual ITD syntax when using @AspectJ
   // public static is mandatory
   // the field type must be the introduced interface. It can't be a class.
   @DeclareParents(value="C", defaultImpl=MoodyImpl.class)
   Moody introduced;

//   @Before("execution(* *.*(..)) && this(m)")
//   public void feelingMoody(Moody m) {
//      System.out.println("I'm feeling " + m.getMood());
//   }

  public static void main(String []argv) {
    ((Moody)new C()).getMood(7);
  }
}


class C {
  
}