class InjectionHandle internal constructor( val id: String )Handle for a registered injection, used for rollback operations.
Properties
| Property | Description |
|---|---|
id | Injection registration id, used for rollback |
Common
class InjectionHandle internal constructor( val id: String )Handle for a registered injection, used for rollback operations.
| Property | Description |
|---|---|
id | Injection registration id, used for rollback |
class InjectionInvocationContext internal constructor( private val delegate: InjectionManager.InjectionInvocation )Invocation context passed to unsafe callbacks.
Provides access to the method being invoked, the receiver instance, arguments, and control over the invocation flow.
| Property | Description |
|---|---|
delegate | The underlying injection invocation delegate |
val method: MethodMethod currently being invoked.
val instance: Any?Method receiver instance, or null for static methods.
val arguments: Array<Any?>Raw argument array.
val owner: String?Bound script owner for this invocation.
fun setArgument(index: Int, value: Any?)Mutates argument at [index] for current invocation.
| Parameter | Description |
|---|---|
index | The argument index to modify |
value | The new value for the argument |
fun cancel()Cancels current invocation. Return value becomes type default if not overridden.
fun cancelWith(returnValue: Any?)Cancels current invocation and overrides return value immediately.
| Parameter | Description |
|---|---|
returnValue | The value to return instead of executing the method |
fun setReturnValue(returnValue: Any?)Overrides return value in after phase.
| Parameter | Description |
|---|---|
returnValue | The value to return instead of the original result |
class ConstructorInvocationContext internal constructor( private val delegate: InjectionManager.ConstructorInvocation )Constructor invocation context passed to unsafe constructor callbacks.
| Property | Description |
|---|---|
delegate | The underlying constructor invocation delegate |
val constructor: Constructor<*>Constructor currently being invoked.
val instance: Any?Constructed instance (this) when available.
val arguments: Array<Any?>Raw constructor argument array.
val owner: String?Bound script owner for this invocation.
fun injectBefore(targetClassName: String, methodName: String, parameterTypeNames: List<String> = emptyList(), owner: String? = null, handler: (InjectionInvocationContext) -> Unit): InjectionHandleInjects a callback before target method execution (string-based overload).
| Parameter | Description |
|---|---|
targetClassName | target class fully-qualified name |
methodName | target method name |
parameterTypeNames | parameter type names, e.g. int, java.lang.String |
owner | script owner (nullable, auto-resolved from script context if null) |
handler | before callback |
injection handle, usable by [rollbackUnsafe]
fun injectBefore(method: Method, owner: String? = null, handler: (InjectionInvocationContext) -> Unit): InjectionHandleInjects a callback before target method execution (Method overload).
Prefer this overload when a reflected [Method] is already available, to avoid string-signature assembly errors.
fun injectAfter(targetClassName: String, methodName: String, parameterTypeNames: List<String> = emptyList(), owner: String? = null, handler: (InjectionInvocationContext, Any?, Throwable?) -> Unit): InjectionHandleInjects a callback after target method execution (string-based overload).
| Parameter | Description |
|---|---|
targetClassName | target class fully-qualified name |
methodName | target method name |
parameterTypeNames | parameter type names, e.g. int, java.lang.String |
owner | script owner (nullable, auto-resolved from script context if null) |
handler | after callback with result and throwable |
injection handle, usable by [rollbackUnsafe]
fun injectConstructorBefore(targetClassName: String, parameterTypeNames: List<String> = emptyList(), owner: String? = null, handler: (ConstructorInvocationContext) -> Unit): InjectionHandleInjects a callback before constructor execution (string-based overload).
| Parameter | Description |
|---|---|
targetClassName | target class fully-qualified name |
parameterTypeNames | constructor parameter type names, e.g. int, java.lang.String |
owner | script owner (nullable, auto-resolved from script context if null) |
handler | constructor-before callback |
injection handle, usable by [rollbackUnsafe]
fun injectConstructorBefore(constructor: Constructor<*>, owner: String? = null, handler: (ConstructorInvocationContext) -> Unit): InjectionHandleInjects a callback before constructor execution (Constructor overload).
fun injectConstructorAfter(targetClassName: String, parameterTypeNames: List<String> = emptyList(), owner: String? = null, handler: (ConstructorInvocationContext) -> Unit): InjectionHandleInjects a callback after constructor execution (string-based overload).
| Parameter | Description |
|---|---|
targetClassName | target class fully-qualified name |
parameterTypeNames | constructor parameter type names, e.g. int, java.lang.String |
owner | script owner (nullable, auto-resolved from script context if null) |
handler | constructor-after callback |
injection handle, usable by [rollbackUnsafe]
fun injectConstructorAfter(constructor: Constructor<*>, owner: String? = null, handler: (ConstructorInvocationContext) -> Unit): InjectionHandleInjects a callback after constructor execution (Constructor overload).
fun injectAfter(method: Method, owner: String? = null, handler: (InjectionInvocationContext, Any?, Throwable?) -> Unit): InjectionHandleInjects a callback after target method execution (Method overload).
Prefer this overload when a reflected [Method] is already available.
| Parameter | Description |
|---|---|
method | The target Method to inject into |
owner | Script owner (nullable, auto-resolved from script context if null) |
handler | After callback with result and throwable |
Injection handle, usable by [rollbackUnsafe]
fun replace(targetClassName: String, methodName: String, parameterTypeNames: List<String> = emptyList(), owner: String? = null, handler: (InjectionInvocationContext) -> Any?): InjectionHandleReplaces entire target method body (string-based overload).
The handler return value becomes the method return value. This completely bypasses the original method implementation.
| Parameter | Description |
|---|---|
targetClassName | Target class fully-qualified name |
methodName | Target method name |
parameterTypeNames | Parameter type names, e.g. int, java.lang.String |
owner | Script owner (nullable, auto-resolved from script context if null) |
handler | Replacement handler that returns the method result |
Injection handle, usable by [rollbackUnsafe]
fun replace(method: Method, owner: String? = null, handler: (InjectionInvocationContext) -> Any?): InjectionHandleReplaces entire target method body (Method overload).
| Parameter | Description |
|---|---|
method | The target Method to replace |
owner | Script owner (nullable, auto-resolved from script context if null) |
handler | Replacement handler that returns the method result |
Injection handle, usable by [rollbackUnsafe]
fun redirect(sourceClassName: String, sourceMethodName: String, sourceParameterTypeNames: List<String> = emptyList(), targetClassName: String, targetMethodName: String, targetParameterTypeNames: List<String> = emptyList(), owner: String? = null): InjectionHandleRedirects a source method to another target method (string-based overload).
All calls to the source method will be redirected to the target method instead.
| Parameter | Description |
|---|---|
sourceClassName | Source class fully-qualified name |
sourceMethodName | Source method name to redirect from |
sourceParameterTypeNames | Source method parameter type names |
targetClassName | Target class fully-qualified name |
targetMethodName | Target method name to redirect to |
targetParameterTypeNames | Target method parameter type names |
owner | Script owner (nullable, auto-resolved from script context if null) |
Injection handle, usable by [rollbackUnsafe]
fun redirect(sourceMethod: Method, targetMethod: Method, owner: String? = null): InjectionHandleRedirects a source method to another target method (Method overload).
| Parameter | Description |
|---|---|
sourceMethod | The source Method to redirect from |
targetMethod | The target Method to redirect to |
owner | Script owner (nullable, auto-resolved from script context if null) |
Injection handle, usable by [rollbackUnsafe]
fun rollbackUnsafeByOwner(owner: String)Rolls back all unsafe injections by owner.
| Parameter | Description |
|---|---|
owner | The script owner whose injections should be removed |