GuardedInvocation (Java SE 15 & JDK 15) (original) (raw)


public class GuardedInvocation extends Object

Represents a conditionally valid method handle. Usually produced as a return value ofGuardingDynamicLinker.getGuardedInvocation(LinkRequest, LinkerServices) andGuardingTypeConverterFactory.convertToType(Class, Class, Supplier). It is an immutable tuple of an invocation method handle, a guard method handle that defines the applicability of the invocation handle, zero or more switch points that can be used for external invalidation of the invocation handle, and an exception type that if thrown during an invocation of the method handle also invalidates it. The invocation handle is suitable for invocation if the guard handle returns true for its arguments, and as long as any of the switch points are not invalidated, and as long as it does not throw an exception of the designated type. The guard, the switch points, and the exception type are all optional (a guarded invocation having none of them is unconditionally valid).

Constructors

Constructor Description
GuardedInvocation​(MethodHandle invocation) Creates a new unconditional guarded invocation.
GuardedInvocation​(MethodHandle invocation,MethodHandle guard) Creates a new guarded invocation, with a guard method handle.
GuardedInvocation​(MethodHandle invocation,MethodHandle guard,SwitchPoint switchPoint) Creates a new guarded invocation, with both a guard method handle and a switch point that can be used to invalidate it.
GuardedInvocation​(MethodHandle invocation,MethodHandle guard,SwitchPoint[] switchPoints,Class<? extends Throwable> exception) Creates a new guarded invocation, with a guard method handle, any number of switch points that can be used to invalidate it, and an exception that if thrown when invoked also invalidates it.
GuardedInvocation​(MethodHandle invocation,MethodHandle guard,SwitchPoint switchPoint,Class<? extends Throwable> exception) Creates a new guarded invocation, with a guard method handle, a switch point that can be used to invalidate it, and an exception that if thrown when invoked also invalidates it.
GuardedInvocation​(MethodHandle invocation,SwitchPoint switchPoint) Creates a new guarded invocation that can be invalidated by a switch point.
Modifier and Type Method Description
GuardedInvocation addSwitchPoint​(SwitchPoint newSwitchPoint) Create a new guarded invocation with an added switch point.
GuardedInvocation asType​(MethodType newType) Changes the type of the invocation, as ifMethodHandle.asType(MethodType) was applied to its invocation and its guard, if it has one (with return type changed to boolean, and parameter count potentially truncated for the guard).
GuardedInvocation asType​(CallSiteDescriptor desc) Changes the type of the invocation, as ifMethodHandle.asType(MethodType) was applied to its invocation and its guard, if it has one (with return type changed to boolean for guard).
GuardedInvocation asType​(LinkerServices linkerServices,MethodType newType) Changes the type of the invocation, as ifLinkerServices.asType(MethodHandle, MethodType) was applied to its invocation and its guard, if it has one (with return type changed to boolean, and parameter count potentially truncated for the guard).
GuardedInvocation asTypeSafeReturn​(LinkerServices linkerServices,MethodType newType) Changes the type of the invocation, as ifLinkerServices.asTypeLosslessReturn(MethodHandle, MethodType) was applied to its invocation andLinkerServices.asType(MethodHandle, MethodType) applied to its guard, if it has one (with return type changed to boolean, and parameter count potentially truncated for the guard).
MethodHandle compose​(MethodHandle fallback) Composes the invocation, guard, switch points, and the exception into a composite method handle that knows how to fall back when the guard fails or the invocation is invalidated.
MethodHandle compose​(MethodHandle guardFallback,MethodHandle switchpointFallback,MethodHandle catchFallback) Composes the invocation, guard, switch points, and the exception into a composite method handle that knows how to fall back when the guard fails or the invocation is invalidated.
GuardedInvocation dropArguments​(int pos,Class<?>... valueTypes) Makes an invocation that drops arguments in both the invocation and the guard (if it exists and has at least pos parameters) withMethodHandles.dropArguments(MethodHandle, int, Class...).
GuardedInvocation dropArguments​(int pos,List<Class<?>> valueTypes) Makes an invocation that drops arguments in both the invocation and the guard (if it exists and has at least pos parameters) withMethodHandles.dropArguments(MethodHandle, int, List).
GuardedInvocation filterArguments​(int pos,MethodHandle... filters) Applies argument filters to both the invocation and the guard (if it exists and has at least pos + 1 parameters) withMethodHandles.filterArguments(MethodHandle, int, MethodHandle...).
Class<? extends Throwable> getException() Returns the exception type that if thrown by the invocation should invalidate the linkage of this guarded invocation.
MethodHandle getGuard() Returns the guard method handle.
MethodHandle getInvocation() Returns the invocation method handle.
SwitchPoint[] getSwitchPoints() Returns the switch points that can be used to invalidate the linkage of this invocation handle.
boolean hasBeenInvalidated() Returns true if and only if this guarded invocation has at least one invalidated switch point.
GuardedInvocation replaceMethods​(MethodHandle newInvocation,MethodHandle newGuard) Creates a new guarded invocation with different methods, preserving the switch point.

Methods declared in class java.lang.Object

[clone](../../../../java.base/java/lang/Object.html#clone%28%29), [equals](../../../../java.base/java/lang/Object.html#equals%28java.lang.Object%29), [finalize](../../../../java.base/java/lang/Object.html#finalize%28%29), [getClass](../../../../java.base/java/lang/Object.html#getClass%28%29), [hashCode](../../../../java.base/java/lang/Object.html#hashCode%28%29), [notify](../../../../java.base/java/lang/Object.html#notify%28%29), [notifyAll](../../../../java.base/java/lang/Object.html#notifyAll%28%29), [toString](../../../../java.base/java/lang/Object.html#toString%28%29), [wait](../../../../java.base/java/lang/Object.html#wait%28%29), [wait](../../../../java.base/java/lang/Object.html#wait%28long%29), [wait](../../../../java.base/java/lang/Object.html#wait%28long,int%29)