summaryrefslogtreecommitdiffstats
path: root/tests/bugs150/pr100195.aj
blob: 816711e894cc8a1dc15715165f6ac92ee5c3f77d (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
59
60
61
62
import org.aspectj.testing.Tester;

public class pr100195 {
    public static void main(String[] args) {
        new Foo().foo();
        AroundCasting.main(new String[0]);
    }	
}

class Foo {
	
    static int x;
	
    private String myString = "A String";
 
    public static void main(String[] args) {
        new Foo().foo();
        AroundCasting.main(new String[0]);
    }
 
    public void foo() {
      String myLocal = myString;
      x = 5;
      System.out.println(myLocal);   // breakpoint here
      bar(x);
    }
    
    public void bar(int y) {}
}
// Test.aj
aspect Test {
  void around() : ( execution(* Foo.foo(..) ) ) {
	  int y = 4;
      System.out.println("before");
      proceed();
      System.out.println("after");
  }
}

class AroundCasting {
    public static void main(String[] args) {
    	bar(x);
        //Tester.checkEqual(x, 1003);
    }
    static int x;
    
    static void bar(int y) {}
}


aspect A {
    static boolean test() { return true; }

    int around(): if (test()) && get(int AroundCasting.x) {
        return proceed() + 1000;
    }

    void around(): execution(void AroundCasting.main(String[])) {
        Tester.event("enter main");
        proceed();
    }
}