summaryrefslogtreecommitdiffstats
path: root/tests/java5/ataspectj/annotationGen/DeclareSoftTest.aj
blob: 0dd4c1f6f2cbe1a90a4050fac268b56628e4fecc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import org.aspectj.lang.reflect.*;
import java.lang.reflect.*;

public aspect DeclareSoftTest {
	
	declare soft : ClassNotFoundException : call(* Class.forName(..));

	
	public static void main(String[] args) throws ClassNotFoundException {
		AjType<DeclareSoftTest> myType = AjTypeSystem.getAjType(DeclareSoftTest.class);
		DeclareSoft[] decSs = myType.getDeclareSofts();
		if (decSs.length != 1) throw new RuntimeException("Expecting 1 members, got " + decSs.length);
		if (decSs[0].getDeclaringType() != myType) throw new RuntimeException("Bad declaring type: " + decSs[0].getDeclaringType());
		String pc = decSs[0].getPointcutExpression().asString();
		if (!pc.equals("call(* java.lang.Class.forName(..))")) throw new RuntimeException("Bad pcut: " + pc);
		AjType exType = decSs[0].getSoftenedExceptionType();
		if (exType != AjTypeSystem.getAjType(ClassNotFoundException.class)) {
			throw new RuntimeException("Bad ex type: " + exType);
		}
	}
	
}