public final class MethodVariantSupport
extends Object
Runtime support for a method-level Decreases recursion termination measure. Code generated by MethodVariantASTTransformation wraps the method body so that on entry enter records the measure (keyed by method signature, per thread) and, when the method is already on the stack — i.e. this is a recursive re-entry — checks that the measure strictly decreased and is non-negative. exit restores the enclosing frame's value on return.
Because the check is pure entry/exit bookkeeping it needs no static analysis of recursive call sites: any re-entry of the same method (direct, mutual, or via a callback) is compared against its nearest enclosing frame.
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static Object |
enter(String key, String className, Object measure)Record this invocation's measure for key (unless disabled for
className by -ea/-da). |
|
public static void |
exit(String key, Object prev)Restore the enclosing invocation's measure on return from key (a no-op
when checks were disabled). |
Record this invocation's measure for key (unless disabled for
className by -ea/-da). If an enclosing invocation of
the same method is already active — a recursive re-entry — verify the measure
strictly decreased and remained non-negative, raising a
RecursionVariantViolation otherwise. Returns the value exit
must restore.
key - the method's signature keyclassName - the declaring class name (for -ea/-da gating)measure - the measure value for this invocationnull if outermost, or a
disabled sentinel