modify

abstract fun modify(key: String, self: Any, args: Array<Any>, returned: Any, thrown: Throwable): PatchDecision

Called as the patched method leaves, on both exit paths.

Return

Patches.proceed() to keep returned, or Patches.returns(v) to replace it. A value of the wrong type is refused and counted as a handler failure.

Parameters

key

the patch key that fired

self

the receiver of the patched method (null for static methods)

args

the arguments as they reached this patch, boxed. A reassignment inside the body does not show here; a change to an argument object does. Read-only here — the body has already run, so writing them changes nothing

returned

the return value, boxed; null for void methods, and meaningless when thrown is non-null

thrown

the exception leaving the method, or null on a normal return