0
# Reflection API
1
2
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.
3
4
## Capabilities
5
6
### AjType Interface
7
8
AspectJ representation of a type that provides access to AspectJ-specific type information.
9
10
```java { .api }
11
/**
12
* AspectJ representation of a type that provides access to AspectJ specific type information
13
*/
14
public interface AjType<T> {
15
String getName();
16
Class<T> getJavaClass();
17
AjType<?>[] getInterfaces();
18
boolean isAspect();
19
Aspect getAspectAnnotation();
20
PerClause getPerClause();
21
Pointcut[] getPointcuts();
22
Advice[] getAdvice();
23
InterTypeMethodDeclaration[] getITDMethods();
24
InterTypeFieldDeclaration[] getITDFields();
25
InterTypeConstructorDeclaration[] getITDConstructors();
26
}
27
```
28
29
### AjTypeSystem
30
31
Provides access to the AspectJ type system for obtaining AjType instances.
32
33
```java { .api }
34
/**
35
* Provides access to the AspectJ type system
36
*/
37
public class AjTypeSystem {
38
/**
39
* Returns AjType for given class
40
*/
41
public static AjType<?> getAjType(Class<?> clazz);
42
43
/**
44
* Returns AjTypes for given classes
45
*/
46
public static AjType<?>[] getAjTypes(Class<?>[] classes);
47
}
48
```
49
50
### Per Clause Support
51
52
```java { .api }
53
public enum PerClauseKind {
54
SINGLETON, PERCFLOW, PERCFLOWBELOW, PERTARGET, PERTHIS, PERTYPEWITHIN
55
}
56
57
public interface PerClause {
58
PerClauseKind getKind();
59
}
60
```
61
62
## Usage Examples
63
64
```java
65
// Inspect aspect metadata
66
AjType<?> aspectType = AjTypeSystem.getAjType(LoggingAspect.class);
67
if (aspectType.isAspect()) {
68
System.out.println("Per clause: " + aspectType.getPerClause().getKind());
69
for (Pointcut pc : aspectType.getPointcuts()) {
70
System.out.println("Pointcut: " + pc.getName());
71
}
72
for (Advice advice : aspectType.getAdvice()) {
73
System.out.println("Advice: " + advice.getKind());
74
}
75
}
76
```