summaryrefslogtreecommitdiffstats
path: root/tests/java5/ataspectj/annotationGen/DeclareParentsTestAdvanced.aj
blob: 12d516e94f2199642a8b2f580d27affa792e2184 (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
package a.b.c;

import org.aspectj.lang.reflect.*;
import java.lang.reflect.*;

public class DeclareParentsTestAdvanced {
	
	public static void main(String[] args) throws ClassNotFoundException {
		AjType<ConcreteAspect> aType = AjTypeSystem.getAjType(ConcreteAspect.class);
		DeclareParents[] decPs = aType.getDeclareParents();
		if (decPs.length != 1) throw new RuntimeException("should see decp from super");
		DeclareParents dp = decPs[0];
		if (!dp.isImplements()) throw new RuntimeException("Expecting implements");
		if (dp.getDeclaringType().getJavaClass() != AbstractAspect.class) {
			throw new RuntimeException("Expecting declaring class to be AbstractAspect");
		}
		TypePattern tp = dp.getTargetTypesPattern();
		if (!tp.asString().equals("a.b.c.A")) {
			throw new RuntimeException("expecting 'a.b.c.A' but was '" + tp.asString() + "'");
		}
		Type[] parents = dp.getParentTypes();
		if (parents.length != 1) throw new RuntimeException("expecting 1 parent");
		if (((AjType)parents[0]).getJavaClass() != B.class) {
			throw new RuntimeException("expecting 'B' but was '" + parents[0].toString() + "'");
		}
	}
}

abstract aspect AbstractAspect {
	
	declare parents : A implements B;
	
}

aspect ConcreteAspect extends AbstractAspect {}

class A {}

class B {}