summaryrefslogtreecommitdiffstats
path: root/tests/bugs/PR68991/Simple.java
blob: f6afa8e10bef42cbf364f8c849e7df666c5517d6 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.util.*;

aspect Aspect {
	
	public static List tjps = new ArrayList();
	public static List values = new ArrayList();
	public static List ejps = new ArrayList();
	
	public  int C.m = 13;
    private int C.n = 13;

    before() : get(* C.*) {
    	tjps.add(thisJoinPointStaticPart.toString());
    	ejps.add(thisEnclosingJoinPointStaticPart.toString());
    	//System.out.println("get field "+thisJoinPointStaticPart);
    }

    before(int x) : set(* C.*) && args(x)  {
    	tjps.add(thisJoinPointStaticPart.toString());
    	ejps.add(thisEnclosingJoinPointStaticPart.toString());
    	values.add(new String(thisJoinPointStaticPart+"="+new Integer(x)));
    	//System.err.println("set field "+thisJoinPointStaticPart);
    }
    
    public void C.foo() {
    	m++;
    	n++;
    }

}

class C {
  //  int m = 20;
}

public class Simple {

    public static void main(String[] args) {
    	C c = new C();
    	c.foo();
    	System.err.println("\nSummaryJPs:"+Aspect.tjps);
    	System.err.println("\nSummaryEJPs:"+Aspect.ejps);
    	System.err.println("\nSummaryVals:"+Aspect.values);
    	// Ought to have a nicer signature for the ejpsp in the case of an initializer ...
    	chkNext(Aspect.tjps,"set(int C.m)");chkNext(Aspect.values,"set(int C.m)=13");chkNext(Aspect.ejps,"execution(void Aspect.ajc$interFieldInit$Aspect$C$m(C))");
    	chkNext(Aspect.tjps,"set(int C.n)");chkNext(Aspect.values,"set(int C.n)=13");chkNext(Aspect.ejps,"execution(void Aspect.ajc$interFieldInit$Aspect$C$n(C))");
    	chkNext(Aspect.tjps,"get(int C.m)");                                         chkNext(Aspect.ejps,"execution(void C.foo())");
    	chkNext(Aspect.tjps,"set(int C.m)");chkNext(Aspect.values,"set(int C.m)=14");chkNext(Aspect.ejps,"execution(void C.foo())");
    	chkNext(Aspect.tjps,"get(int C.n)");                                         chkNext(Aspect.ejps,"execution(void C.foo())");
    	chkNext(Aspect.tjps,"set(int C.n)");chkNext(Aspect.values,"set(int C.n)=14");chkNext(Aspect.ejps,"execution(void C.foo())");
    }
    
    public static void chkNext(List l,String expected) {
    	String s = (String)l.remove(0);
    	if (!s.equals(expected)) throw new RuntimeException("Expected next thing on list to be '"+expected+"' but it was '"+s+"'");
    }

}