aboutsummaryrefslogtreecommitdiffstats
path: root/tests/design/soft/DeclareSoft.aj
blob: 37da96725283af2ba616f4340c2641162692fda8 (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
public class DeclareSoft {
    
    public void throwException() throws Exception {
        throw new Exception("This should be softened");
    }
    
    public void throwRuntimeException() {
        throw new RuntimeException("Under enh 42743 this should not be softened");
    }
    
    public static void main(String[] args) throws Exception {
        DeclareSoft ds = new DeclareSoft();
        try {
            ds.throwException();
        } catch (org.aspectj.lang.SoftException se) {}
        try {
            ds.throwRuntimeException();
        } catch(org.aspectj.lang.SoftException se) {
            throw new RuntimeException("Runtime exception was innappropriately softened");
        } catch (RuntimeException ex) {}
    }
    
}

aspect Softener {
    
    declare soft: Exception : execution(* DeclareSoft.throw*(..));
    
}