CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-aspectj--aspectjrt

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.

Pending
Overview
Eval results
Files

signature-system.mddocs/

Signature System

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.

Capabilities

Base Signature Interface

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

/**
 * Represents the signature at a join point. This interface parallels
 * java.lang.reflect.Member.
 */
public interface Signature {
    /**
     * Returns the identifier part of this signature (method name, field name, etc.)
     */
    String getName();
    
    /**
     * Returns the modifiers on this signature represented as an int.
     * Use java.lang.reflect.Modifier constants and helper methods.
     */
    int getModifiers();
    
    /**
     * Returns a Class object representing the class, interface, or aspect
     * that declared this member.
     */
    Class getDeclaringType();
    
    /**
     * Returns the fully qualified name of the declaring type (cached for efficiency)
     */
    String getDeclaringTypeName();
    
    String toString();
    String toShortString();
    String toLongString();
}

Method Signatures

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

/**
 * Signature for method execution and call join points
 */
public interface MethodSignature extends MemberSignature {
    /**
     * Returns the return type of this method
     */
    Class getReturnType();
    
    /**
     * Returns the Method object for this signature
     */
    Method getMethod();
    
    /**
     * Returns the parameter types of this method
     */
    Class[] getParameterTypes();
    
    /**
     * Returns the parameter names of this method
     */
    String[] getParameterNames();
    
    /**
     * Returns the exception types declared by this method
     */
    Class[] getExceptionTypes();
}

Constructor Signatures

Signature for constructor execution and call join points.

/**
 * Signature for constructor execution and call join points
 */
public interface ConstructorSignature extends CodeSignature {
    /**
     * Returns the Constructor object for this signature
     */
    Constructor getConstructor();
}

Field Signatures

Signature for field get and set join points.

/**
 * Signature for field get and set join points
 */
public interface FieldSignature extends MemberSignature {
    /**
     * Returns the type of the field
     */
    Class getFieldType();
    
    /**
     * Returns the Field object for this signature
     */
    Field getField();
}

Advice Signatures

Signature for advice execution join points.

/**
 * Signature for advice execution join points
 */
public interface AdviceSignature extends CodeSignature {
    /**
     * Returns the return type of this advice
     */
    Class getReturnType();
    
    /**
     * Returns the exception types declared by this advice
     */
    Class[] getExceptionTypes();
}

Usage Examples

Method Signature Analysis

@Aspect
public class MethodAnalysisAspect {
    
    @Before("execution(* com.example.service.*.*(..))")
    public void analyzeMethod(JoinPoint joinPoint) {
        Signature sig = joinPoint.getSignature();
        
        if (sig instanceof MethodSignature) {
            MethodSignature methodSig = (MethodSignature) sig;
            
            System.out.println("Method: " + methodSig.getName());
            System.out.println("Return type: " + methodSig.getReturnType().getSimpleName());
            System.out.println("Parameters: " + Arrays.toString(methodSig.getParameterTypes()));
            System.out.println("Parameter names: " + Arrays.toString(methodSig.getParameterNames()));
            System.out.println("Exceptions: " + Arrays.toString(methodSig.getExceptionTypes()));
            System.out.println("Modifiers: " + Modifier.toString(methodSig.getModifiers()));
            System.out.println("Declaring type: " + methodSig.getDeclaringType().getName());
        }
    }
}

Field Access Monitoring

@Aspect
public class FieldAccessAspect {
    
    @Before("get(* com.example.model.*.*) || set(* com.example.model.*.*)")
    public void monitorFieldAccess(JoinPoint joinPoint) {
        FieldSignature fieldSig = (FieldSignature) joinPoint.getSignature();
        
        System.out.println("Field access: " + fieldSig.getName());
        System.out.println("Field type: " + fieldSig.getFieldType().getSimpleName());
        System.out.println("Owner: " + fieldSig.getDeclaringType().getSimpleName());
        System.out.println("Access type: " + joinPoint.getKind());
        
        if ("field-set".equals(joinPoint.getKind())) {
            Object[] args = joinPoint.getArgs();
            if (args.length > 0) {
                System.out.println("New value: " + args[0]);
            }
        }
    }
}

Constructor Interception

@Aspect
public class ConstructorAspect {
    
    @Before("execution(com.example.model.*.new(..))")
    public void beforeConstruction(JoinPoint joinPoint) {
        ConstructorSignature conSig = (ConstructorSignature) joinPoint.getSignature();
        
        System.out.println("Creating: " + conSig.getDeclaringType().getSimpleName());
        System.out.println("Constructor parameters: " + Arrays.toString(conSig.getParameterTypes()));
        System.out.println("Arguments: " + Arrays.toString(joinPoint.getArgs()));
        
        Constructor constructor = conSig.getConstructor();
        System.out.println("Modifiers: " + Modifier.toString(constructor.getModifiers()));
    }
}

Signature Hierarchy

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

// Base interfaces
public interface Signature { /* base signature information */ }
public interface MemberSignature extends Signature { /* member-specific information */ }
public interface CodeSignature extends MemberSignature { /* executable code signatures */ }

// Specific signature types
public interface MethodSignature extends MemberSignature { /* method-specific */ }
public interface ConstructorSignature extends CodeSignature { /* constructor-specific */ }
public interface FieldSignature extends MemberSignature { /* field-specific */ }
public interface AdviceSignature extends CodeSignature { /* advice-specific */ }
public interface InitializerSignature extends CodeSignature { /* initializer-specific */ }
public interface CatchClauseSignature extends CodeSignature { /* exception handler-specific */ }
public interface LockSignature extends Signature { /* synchronization lock-specific */ }
public interface UnlockSignature extends Signature { /* synchronization unlock-specific */ }

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

Install with Tessl CLI

npx tessl i tessl/maven-org-aspectj--aspectjrt

docs

annotation-based-definition.md

aspect-management.md

index.md

join-point-introspection.md

reflection-api.md

runtime-utilities.md

signature-system.md

tile.json