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 argument slots as they stand at exit, boxed. 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