The AspectJ runtime is a small library necessary to run Java programs enhanced by AspectJ aspects during a previous compile-time or post-compile-time (binary weaving) build step.
—
AspectJ-specific type system that extends Java reflection to provide access to aspect-oriented features like pointcuts, advice, inter-type declarations, and per-clauses. The reflection API enables runtime introspection of aspects and aspect-enhanced classes, supporting dynamic aspect discovery and programmatic access to aspect metadata.
AspectJ representation of a type that provides access to AspectJ-specific type information.
/**
* AspectJ representation of a type that provides access to AspectJ specific type information
*/
public interface AjType<T> {
String getName();
Class<T> getJavaClass();
AjType<?>[] getInterfaces();
boolean isAspect();
Aspect getAspectAnnotation();
PerClause getPerClause();
Pointcut[] getPointcuts();
Advice[] getAdvice();
InterTypeMethodDeclaration[] getITDMethods();
InterTypeFieldDeclaration[] getITDFields();
InterTypeConstructorDeclaration[] getITDConstructors();
}Provides access to the AspectJ type system for obtaining AjType instances.
/**
* Provides access to the AspectJ type system
*/
public class AjTypeSystem {
/**
* Returns AjType for given class
*/
public static AjType<?> getAjType(Class<?> clazz);
/**
* Returns AjTypes for given classes
*/
public static AjType<?>[] getAjTypes(Class<?>[] classes);
}public enum PerClauseKind {
SINGLETON, PERCFLOW, PERCFLOWBELOW, PERTARGET, PERTHIS, PERTYPEWITHIN
}
public interface PerClause {
PerClauseKind getKind();
}// Inspect aspect metadata
AjType<?> aspectType = AjTypeSystem.getAjType(LoggingAspect.class);
if (aspectType.isAspect()) {
System.out.println("Per clause: " + aspectType.getPerClause().getKind());
for (Pointcut pc : aspectType.getPointcuts()) {
System.out.println("Pointcut: " + pc.getName());
}
for (Advice advice : aspectType.getAdvice()) {
System.out.println("Advice: " + advice.getKind());
}
}Install with Tessl CLI
npx tessl i tessl/maven-org-aspectj--aspectjrt