public final class SwitchPointInvalidator
extends Object
Lazily allocates a SwitchPoint and retires it on demand.
Call sites install the switch point returned by getSwitchPoint() in
guardWithTest chains. invalidate() retires the live switch
point so linked sites fall back and re-link; the next getSwitchPoint()
allocates a fresh one.
Bulk paths (category enter/leave, custom MetaClass events) should prefer detachLive() and a single SwitchPoint.invalidateAll over many individual invalidate() calls (GROOVY-12191).
There is no permanent failover: after scoping stock invalidation to a single class, deopt storms from a process-wide SwitchPoint no longer apply, so a simpler replace-on-invalidate model is sufficient.
| Constructor and description |
|---|
SwitchPointInvalidator()Creates an invalidator with no live SwitchPoint until the first getSwitchPoint() call. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public SwitchPoint |
detachLive()Atomically detaches the live switch point for bulk SwitchPoint.invalidateAll without invalidating it yet. |
|
public int |
getRetirementCount()Returns how many live switch points have been retired. |
|
public SwitchPoint |
getSwitchPoint()Returns a live switch point to install in a call-site guard chain. |
|
public void |
invalidate()Invalidates the current live switch point (if any) so linked sites re-link. |
|
public static void |
invalidateIfLive(SwitchPoint sp)Invalidates sp when non-null and still valid. |
Creates an invalidator with no live SwitchPoint until the first getSwitchPoint() call. Field initializers own all state.
Atomically detaches the live switch point for bulk SwitchPoint.invalidateAll without invalidating it yet. The caller must invalidate any non-null return value.
null if none was liveReturns how many live switch points have been retired.
Returns a live switch point to install in a call-site guard chain. Lazily allocates on first use after construction or after retirement.
null)Invalidates the current live switch point (if any) so linked sites re-link. A subsequent getSwitchPoint() allocates a fresh switch point.
Invalidates sp when non-null and still valid.
sp - candidate switch point (may be null)Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.