aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs/GetCauseOnSoftException.java
blob: 125fce88cfe9b14b0c8502bda84c9c4c817a89b3 (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
import org.aspectj.lang.*;

public class GetCauseOnSoftException {

	public static void a(){
		b();
	}
	/**
	 * Method b.
	 */
	private static void b() {
		throw new MyException("secret");
	}
    
	public static void main(String[] args) {
		try {
			a();
		} catch (SoftException e) {
			System.out.println(e.getCause());
			if (e.getCause().getMessage().indexOf("secret")==-1) 
			  throw new RuntimeException("Didn't get expected cause of SoftException");
		}
	}
}
aspect Softner {
		declare soft : MyException : within(GetCauseOnSoftException);  
}

class MyException extends Exception {
	MyException(String s) { super(s);}
}