JoinPoint

interface JoinPoint(source)

Provides contextual information about an intercepted function call.

A JoinPoint instance is constructed by the AspectK compiler plugin at each intercepted call site and passed to every matching advice function. It exposes the receiver object, static method-signature metadata, and the runtime arguments of the call.

The concrete implementation injected at runtime is io.github.molelabs.aspectk.runtime.internal.DefaultJoinPoint. Advice code should program to this interface rather than the concrete type.

Usage in advice

@Before(target = [Authenticated::class])
fun checkAuth(joinPoint: JoinPoint) {
val receiver = joinPoint.target // null for top-level functions
val name = joinPoint.signature.methodName
val firstArg = joinPoint.args.firstOrNull()
// Type-safe argument access:
val userId = joinPoint.args[0] as? String
}

See also

DefaultJoinPoint

Inheritors

Properties

Link copied to clipboard
abstract val args: List<Any?>

The runtime arguments passed to the intercepted function, in declaration order.

Link copied to clipboard

Compile-time metadata describing the intercepted function, including its name, annotations, and parameter list.

Link copied to clipboard
abstract val target: Any?

The receiver object on which the intercepted function is called, or null for top-level functions and functions called on companion objects.

Functions

Link copied to clipboard

Returns the AnnotationInfo for annotation T present on the intercepted function, or null if no such annotation is present.

Link copied to clipboard
inline fun <T> JoinPoint.getArg(name: String): T

Returns the argument value for the parameter named name, cast to T.

Link copied to clipboard
inline fun <T> JoinPoint.getArgOrNull(name: String): T?

Returns the argument value for the parameter named name, cast to T, or null if no such parameter exists or the value cannot be cast to T.

Link copied to clipboard
inline fun <T> JoinPoint.getTarget(): T

Returns JoinPoint.target cast to T.

Link copied to clipboard
inline fun <T> JoinPoint.getTargetOrNull(): T?

Returns JoinPoint.target cast to T, or null if the target is null or cannot be cast to T.