You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DeclareParentsTestAdvanced.aj 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package a.b.c;
  2. import org.aspectj.lang.reflect.*;
  3. import java.lang.reflect.*;
  4. public class DeclareParentsTestAdvanced {
  5. public static void main(String[] args) throws ClassNotFoundException {
  6. AjType<ConcreteAspect> aType = AjTypeSystem.getAjType(ConcreteAspect.class);
  7. DeclareParents[] decPs = aType.getDeclareParents();
  8. if (decPs.length != 1) throw new RuntimeException("should see decp from super");
  9. DeclareParents dp = decPs[0];
  10. if (!dp.isImplements()) throw new RuntimeException("Expecting implements");
  11. if (dp.getDeclaringType().getJavaClass() != AbstractAspect.class) {
  12. throw new RuntimeException("Expecting declaring class to be AbstractAspect");
  13. }
  14. TypePattern tp = dp.getTargetTypesPattern();
  15. if (!tp.asString().equals("a.b.c.A")) {
  16. throw new RuntimeException("expecting 'a.b.c.A' but was '" + tp.asString() + "'");
  17. }
  18. Type[] parents = dp.getParentTypes();
  19. if (parents.length != 1) throw new RuntimeException("expecting 1 parent");
  20. if (((AjType)parents[0]).getJavaClass() != B.class) {
  21. throw new RuntimeException("expecting 'B' but was '" + parents[0].toString() + "'");
  22. }
  23. }
  24. }
  25. abstract aspect AbstractAspect {
  26. declare parents : A implements B;
  27. }
  28. aspect ConcreteAspect extends AbstractAspect {}
  29. class A {}
  30. class B {}