public class GuardedInvocation extends Object
Constructor and Description |
---|
GuardedInvocation(MethodHandle invocation,
MethodHandle guard)
Creates a new guarded invocation.
|
GuardedInvocation(MethodHandle invocation,
MethodHandle guard,
SwitchPoint switchPoint)
Creates a new guarded invocation.
|
GuardedInvocation(MethodHandle invocation,
SwitchPoint switchPoint,
MethodHandle guard)
Creates a new guarded invocation.
|
Modifier and Type | Method and Description |
---|---|
void |
assertType(MethodType type)
Asserts that the invocation is of the specified type, and the guard (if present) is of the specified type with a
boolean return type.
|
GuardedInvocation |
asType(CallSiteDescriptor desc)
Changes the type of the invocation, as if
MethodHandle.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 if
LinkerServices.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 |
asType(MethodType newType)
Changes the type of the invocation, as if
MethodHandle.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). |
MethodHandle |
compose(MethodHandle fallback)
Composes the invocation, switchpoint, and the guard into a composite method handle that knows how to fall back.
|
MethodHandle |
compose(MethodHandle switchpointFallback,
MethodHandle guardFallback)
Composes the invocation, switchpoint, and the guard into a composite method handle that knows how to fall back.
|
GuardedInvocation |
dropArguments(int pos,
Class<?>... valueTypes)
Makes an invocation that drops arguments in both the invocation and the guard (if there is one).
|
GuardedInvocation |
dropArguments(int pos,
List<Class<?>> valueTypes)
Makes an invocation that drops arguments in both the invocation and the guard (if there is one).
|
GuardedInvocation |
filterArguments(int pos,
MethodHandle... filters)
Applies argument filters to both the invocation and the guard (if there is one).
|
MethodHandle |
getGuard()
Returns the guard method handle.
|
MethodHandle |
getInvocation()
Returns the invocation method handle.
|
SwitchPoint |
getSwitchPoint()
Returns the switch point that can be used to invalidate the invocation handle.
|
boolean |
hasBeenInvalidated()
Returns true if and only if this guarded invocation has a switchpoint, and that switchpoint has been invalidated.
|
GuardedInvocation |
replaceMethods(MethodHandle newInvocation,
MethodHandle newGuard)
Creates a new guarded invocation with different methods, preserving the switch point.
|
public GuardedInvocation(MethodHandle invocation, MethodHandle guard)
invocation
- the method handle representing the invocation. Must not be null.guard
- the method handle representing the guard. Must have the same method type as the invocation, except
it must return boolean. For some useful guards, check out the Guards
class. It can be null to represent
an unconditional invocation, although that is unusual.NullPointerException
- if invocation is null.public GuardedInvocation(MethodHandle invocation, MethodHandle guard, SwitchPoint switchPoint)
invocation
- the method handle representing the invocation. Must not be null.guard
- the method handle representing the guard. Must have the same method type as the invocation, except
it must return boolean. For some useful guards, check out the Guards
class. It can be null. If both it
and the switch point are null, this represents an unconditional invocation, which is legal but unusual.switchPoint
- the optional switch point that can be used to invalidate this linkage.NullPointerException
- if invocation is null.public GuardedInvocation(MethodHandle invocation, SwitchPoint switchPoint, MethodHandle guard)
invocation
- the method handle representing the invocation. Must not be null.switchPoint
- the optional switch point that can be used to invalidate this linkage.guard
- the method handle representing the guard. Must have the same method type as the invocation, except
it must return boolean. For some useful guards, check out the Guards
class. It can be null. If both it
and the switch point are null, this represents an unconditional invocation, which is legal but unusual.NullPointerException
- if invocation is null.public MethodHandle getInvocation()
public MethodHandle getGuard()
public SwitchPoint getSwitchPoint()
public boolean hasBeenInvalidated()
public void assertType(MethodType type)
type
- the asserted typeWrongMethodTypeException
- if the invocation and the guard are not of the expected method type.public GuardedInvocation replaceMethods(MethodHandle newInvocation, MethodHandle newGuard)
newInvocation
- the new invocationnewGuard
- the new guardpublic GuardedInvocation asType(MethodType newType)
MethodHandle.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). If the invocation already is of the required type, returns this object.newType
- the new type of the invocation.public GuardedInvocation asType(LinkerServices linkerServices, MethodType newType)
LinkerServices.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). If the invocation already is of the required type, returns this object.linkerServices
- the linker services to use for the conversionnewType
- the new type of the invocation.public GuardedInvocation asType(CallSiteDescriptor desc)
MethodHandle.asType(MethodType)
was applied to its invocation
and its guard, if it has one (with return type changed to boolean for guard). If the invocation already is of the
required type, returns this object.desc
- a call descriptor whose method type is adapted.public GuardedInvocation filterArguments(int pos, MethodHandle... filters)
pos
- the position of the first argumen being filteredfilters
- the argument filterspublic GuardedInvocation dropArguments(int pos, List<Class<?>> valueTypes)
pos
- the position of the first argument being droppedvalueTypes
- the types of the values being droppedpublic GuardedInvocation dropArguments(int pos, Class<?>... valueTypes)
pos
- the position of the first argument being droppedvalueTypes
- the types of the values being droppedpublic MethodHandle compose(MethodHandle fallback)
fallback
- the fallback method handle in case switchpoint is invalidated or guard returns false.public MethodHandle compose(MethodHandle switchpointFallback, MethodHandle guardFallback)
switchpointFallback
- the fallback method handle in case switchpoint is invalidated.guardFallback
- the fallback method handle in case guard returns false.Copyright © 2016 Attila Szegedi. All rights reserved.