or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

annotation-based-definition.mdaspect-management.mdindex.mdjoin-point-introspection.mdreflection-api.mdruntime-utilities.mdsignature-system.md

signature-system.mddocs/

0

# Signature System

1

2

Rich type system for representing signatures of methods, constructors, fields, advice, and other program elements. Provides complete reflection capabilities with access to modifiers, parameter types, return types, exception specifications, and source location information. The signature hierarchy parallels Java's reflection API while extending it for aspect-oriented programming features.

3

4

## Capabilities

5

6

### Base Signature Interface

7

8

The fundamental interface for all signature types, providing common signature information.

9

10

```java { .api }

11

/**

12

* Represents the signature at a join point. This interface parallels

13

* java.lang.reflect.Member.

14

*/

15

public interface Signature {

16

/**

17

* Returns the identifier part of this signature (method name, field name, etc.)

18

*/

19

String getName();

20

21

/**

22

* Returns the modifiers on this signature represented as an int.

23

* Use java.lang.reflect.Modifier constants and helper methods.

24

*/

25

int getModifiers();

26

27

/**

28

* Returns a Class object representing the class, interface, or aspect

29

* that declared this member.

30

*/

31

Class getDeclaringType();

32

33

/**

34

* Returns the fully qualified name of the declaring type (cached for efficiency)

35

*/

36

String getDeclaringTypeName();

37

38

String toString();

39

String toShortString();

40

String toLongString();

41

}

42

```

43

44

### Method Signatures

45

46

Signature for method execution and call join points with complete method information.

47

48

```java { .api }

49

/**

50

* Signature for method execution and call join points

51

*/

52

public interface MethodSignature extends MemberSignature {

53

/**

54

* Returns the return type of this method

55

*/

56

Class getReturnType();

57

58

/**

59

* Returns the Method object for this signature

60

*/

61

Method getMethod();

62

63

/**

64

* Returns the parameter types of this method

65

*/

66

Class[] getParameterTypes();

67

68

/**

69

* Returns the parameter names of this method

70

*/

71

String[] getParameterNames();

72

73

/**

74

* Returns the exception types declared by this method

75

*/

76

Class[] getExceptionTypes();

77

}

78

```

79

80

### Constructor Signatures

81

82

Signature for constructor execution and call join points.

83

84

```java { .api }

85

/**

86

* Signature for constructor execution and call join points

87

*/

88

public interface ConstructorSignature extends CodeSignature {

89

/**

90

* Returns the Constructor object for this signature

91

*/

92

Constructor getConstructor();

93

}

94

```

95

96

### Field Signatures

97

98

Signature for field get and set join points.

99

100

```java { .api }

101

/**

102

* Signature for field get and set join points

103

*/

104

public interface FieldSignature extends MemberSignature {

105

/**

106

* Returns the type of the field

107

*/

108

Class getFieldType();

109

110

/**

111

* Returns the Field object for this signature

112

*/

113

Field getField();

114

}

115

```

116

117

### Advice Signatures

118

119

Signature for advice execution join points.

120

121

```java { .api }

122

/**

123

* Signature for advice execution join points

124

*/

125

public interface AdviceSignature extends CodeSignature {

126

/**

127

* Returns the return type of this advice

128

*/

129

Class getReturnType();

130

131

/**

132

* Returns the exception types declared by this advice

133

*/

134

Class[] getExceptionTypes();

135

}

136

```

137

138

## Usage Examples

139

140

### Method Signature Analysis

141

142

```java

143

@Aspect

144

public class MethodAnalysisAspect {

145

146

@Before("execution(* com.example.service.*.*(..))")

147

public void analyzeMethod(JoinPoint joinPoint) {

148

Signature sig = joinPoint.getSignature();

149

150

if (sig instanceof MethodSignature) {

151

MethodSignature methodSig = (MethodSignature) sig;

152

153

System.out.println("Method: " + methodSig.getName());

154

System.out.println("Return type: " + methodSig.getReturnType().getSimpleName());

155

System.out.println("Parameters: " + Arrays.toString(methodSig.getParameterTypes()));

156

System.out.println("Parameter names: " + Arrays.toString(methodSig.getParameterNames()));

157

System.out.println("Exceptions: " + Arrays.toString(methodSig.getExceptionTypes()));

158

System.out.println("Modifiers: " + Modifier.toString(methodSig.getModifiers()));

159

System.out.println("Declaring type: " + methodSig.getDeclaringType().getName());

160

}

161

}

162

}

163

```

164

165

### Field Access Monitoring

166

167

```java

168

@Aspect

169

public class FieldAccessAspect {

170

171

@Before("get(* com.example.model.*.*) || set(* com.example.model.*.*)")

172

public void monitorFieldAccess(JoinPoint joinPoint) {

173

FieldSignature fieldSig = (FieldSignature) joinPoint.getSignature();

174

175

System.out.println("Field access: " + fieldSig.getName());

176

System.out.println("Field type: " + fieldSig.getFieldType().getSimpleName());

177

System.out.println("Owner: " + fieldSig.getDeclaringType().getSimpleName());

178

System.out.println("Access type: " + joinPoint.getKind());

179

180

if ("field-set".equals(joinPoint.getKind())) {

181

Object[] args = joinPoint.getArgs();

182

if (args.length > 0) {

183

System.out.println("New value: " + args[0]);

184

}

185

}

186

}

187

}

188

```

189

190

### Constructor Interception

191

192

```java

193

@Aspect

194

public class ConstructorAspect {

195

196

@Before("execution(com.example.model.*.new(..))")

197

public void beforeConstruction(JoinPoint joinPoint) {

198

ConstructorSignature conSig = (ConstructorSignature) joinPoint.getSignature();

199

200

System.out.println("Creating: " + conSig.getDeclaringType().getSimpleName());

201

System.out.println("Constructor parameters: " + Arrays.toString(conSig.getParameterTypes()));

202

System.out.println("Arguments: " + Arrays.toString(joinPoint.getArgs()));

203

204

Constructor constructor = conSig.getConstructor();

205

System.out.println("Modifiers: " + Modifier.toString(constructor.getModifiers()));

206

}

207

}

208

```

209

210

## Signature Hierarchy

211

212

The signature interfaces form a hierarchy that mirrors Java's reflection structure:

213

214

```java { .api }

215

// Base interfaces

216

public interface Signature { /* base signature information */ }

217

public interface MemberSignature extends Signature { /* member-specific information */ }

218

public interface CodeSignature extends MemberSignature { /* executable code signatures */ }

219

220

// Specific signature types

221

public interface MethodSignature extends MemberSignature { /* method-specific */ }

222

public interface ConstructorSignature extends CodeSignature { /* constructor-specific */ }

223

public interface FieldSignature extends MemberSignature { /* field-specific */ }

224

public interface AdviceSignature extends CodeSignature { /* advice-specific */ }

225

public interface InitializerSignature extends CodeSignature { /* initializer-specific */ }

226

public interface CatchClauseSignature extends CodeSignature { /* exception handler-specific */ }

227

public interface LockSignature extends Signature { /* synchronization lock-specific */ }

228

public interface UnlockSignature extends Signature { /* synchronization unlock-specific */ }

229

```

230

231

This design provides type-safe access to signature information while maintaining compatibility with Java's reflection API.