aboutsummaryrefslogtreecommitdiffstats
path: root/tests/new/NullPointerOnGetsSimple.java
blob: 18fbb04ba5a4522da596a4f8e7123feddf4a123a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
public class NullPointerOnGetsSimple {
    public static void main(String[] args) {
        PrintService ps = new PrintService();
        ps.string = "after";
        org.aspectj.testing.Tester.checkEqual("after", ps.string);
    }
}

class PrintService {
    String string = "before";
}

aspect Aspect {
    pointcut needPrinter(PrintService ps): get(String PrintService.string) && target(ps) && 
        !within(Aspect);
    String around(PrintService ps): needPrinter(ps) {
        System.out.println("around");
        org.aspectj.testing.Tester.checkEqual("after", ps.string);
	return ps.string;
    }
}