APIdia Launch Partner
Top Description Fields Constructors Methods
java.lang.invoke

pack-priv final Class IndirectVarHandle

extends VarHandle
Class Inheritance
Imports
jdk.internal.vm.annotation.ForceInline, java.util.function.BiFunction

An indirect var handle can be thought of as an aggregate of the method handles implementing its supported access modes. Its varform contains no method name table (given that some of the method handles composing a bound var handle might not be direct). The set of method handles constituting an indirect var handle are retrieved lazily, to minimize code spinning (since not all the access modes will be used anyway). Indirect var handles are useful when constructing var handle adapters - that is, an adapter var handle can be constructed by extracting the method handles constituting the target var handle, adapting them (using the method handle combinator API) and then repackaging the adapted method handles into a new, indirect var handle.

Field Summary

Modifier and TypeField and Description
private final Class<?>[]
private final VarHandle
private final BiFunction<VarHandle.AccessMode, MethodHandle, MethodHandle>
private final VarHandle
private final Class<?>
Inherited from java.lang.invoke.VarHandle:
exactmethodHandleTablemethodTypeTablevform

Constructor Summary

AccessConstructor and Description
pack-priv
IndirectVarHandle(VarHandle target, Class<?> value, Class<?>[] coordinates, BiFunction<VarHandle.AccessMode, MethodHandle, MethodHandle> handleFactory)

private
IndirectVarHandle(VarHandle target, Class<?> value, Class<?>[] coordinates, BiFunction<VarHandle.AccessMode, MethodHandle, MethodHandle> handleFactory, VarForm form, boolean exact)

Method Summary

Modifier and TypeMethod and Description
pack-priv MethodType
pack-priv VarHandle
asDirect()

Overrides java.lang.invoke.VarHandle.asDirect.

Returns the direct target VarHandle.

pack-priv boolean
checkAccessModeThenIsDirect(VarHandle.AccessDescriptor ad)

Overrides java.lang.invoke.VarHandle.checkAccessModeThenIsDirect.

Validates that the given access descriptors method type matches up with the access mode of this VarHandle, then returns if this is direct.

pack-priv MethodHandle
getMethodHandleUncached(int mode)

Overrides java.lang.invoke.VarHandle.getMethodHandleUncached.

Computes a method handle that can be passed the direct var handle of this var handle with the given access mode.

public boolean
isAccessModeSupported(VarHandle.AccessMode accessMode)

Overrides java.lang.invoke.VarHandle.isAccessModeSupported.

Returns true if the given access mode is supported, otherwise false.

public VarHandle
withInvokeBehavior()

Implements abstract java.lang.invoke.VarHandle.withInvokeBehavior.

Returns a VarHandle, with access to the same variable(s) as this VarHandle, but whose invocation behavior of access mode methods is adjusted to invoke behavior.

public VarHandle
withInvokeExactBehavior()

Implements abstract java.lang.invoke.VarHandle.withInvokeExactBehavior.

Returns a VarHandle, with access to the same variable(s) as this VarHandle, but whose invocation behavior of access mode methods is adjusted to invoke-exact behavior.

Inherited from java.lang.invoke.VarHandle:
accessModeTypeaccessModeTypeaccessModeTypeUncachedacquireFencecompareAndExchangecompareAndExchangeAcquirecompareAndExchangeReleasecompareAndSetcoordinateTypesdescribeConstablefullFencegetgetAcquiregetAndAddgetAndAddAcquiregetAndAddReleasegetAndBitwiseAndgetAndBitwiseAndAcquiregetAndBitwiseAndReleasegetAndBitwiseOrgetAndBitwiseOrAcquiregetAndBitwiseOrReleasegetAndBitwiseXorgetAndBitwiseXorAcquiregetAndBitwiseXorReleasegetAndSetgetAndSetAcquiregetAndSetReleasegetMethodHandlegetOpaquegetVolatilehasInvokeExactBehaviorloadLoadFencereleaseFencesetsetOpaquesetReleasesetVolatilestoreStoreFencetargettoMethodHandletoStringupdateVarFormvarTypeweakCompareAndSetweakCompareAndSetAcquireweakCompareAndSetPlainweakCompareAndSetRelease

Field Detail

coordinatesback to summary
private final Class<?>[] coordinates
directTargetback to summary
private final VarHandle directTarget
handleFactoryback to summary
private final BiFunction<VarHandle.AccessMode, MethodHandle, MethodHandle> handleFactory
targetback to summary
private final VarHandle target
valueback to summary
private final Class<?> value

Constructor Detail

IndirectVarHandleback to summary
pack-priv IndirectVarHandle(VarHandle target, Class<?> value, Class<?>[] coordinates, BiFunction<VarHandle.AccessMode, MethodHandle, MethodHandle> handleFactory)
IndirectVarHandleback to summary
private IndirectVarHandle(VarHandle target, Class<?> value, Class<?>[] coordinates, BiFunction<VarHandle.AccessMode, MethodHandle, MethodHandle> handleFactory, VarForm form, boolean exact)

Method Detail

accessModeTypeUncachedback to summary
pack-priv MethodType accessModeTypeUncached(VarHandle.AccessType at)

Implements abstract java.lang.invoke.VarHandle.accessModeTypeUncached.

Annotations
@Override
asDirectback to summary
pack-priv VarHandle asDirect()

Overrides java.lang.invoke.VarHandle.asDirect.

Doc from java.lang.invoke.VarHandle.asDirect.

Returns the direct target VarHandle. Indirect VarHandle subclasses should implement this method.

Annotations
@Override
@ForceInline
checkAccessModeThenIsDirectback to summary
pack-priv boolean checkAccessModeThenIsDirect(VarHandle.AccessDescriptor ad)

Overrides java.lang.invoke.VarHandle.checkAccessModeThenIsDirect.

Doc from java.lang.invoke.VarHandle.checkAccessModeThenIsDirect.

Validates that the given access descriptors method type matches up with the access mode of this VarHandle, then returns if this is direct. These operations were grouped together to slightly improve efficiency during startup/warmup. A direct VarHandle's VarForm has implementation MemberNames that can be linked directly. If a VarHandle is indirect, it must override isAccessModeSupported and getMethodHandleUncached which access MemberNames.

Annotations
@Override
@ForceInline
getMethodHandleUncachedback to summary
pack-priv MethodHandle getMethodHandleUncached(int mode)

Overrides java.lang.invoke.VarHandle.getMethodHandleUncached.

Doc from java.lang.invoke.VarHandle.getMethodHandleUncached.

Computes a method handle that can be passed the direct var handle of this var handle with the given access mode. Pre/postprocessing such as argument or return value filtering should be done by the returned method handle.

Annotations
@Override
isAccessModeSupportedback to summary
public boolean isAccessModeSupported(VarHandle.AccessMode accessMode)

Overrides java.lang.invoke.VarHandle.isAccessModeSupported.

Doc from java.lang.invoke.VarHandle.isAccessModeSupported.

Returns true if the given access mode is supported, otherwise false.

The return of a false value for a given access mode indicates that an UnsupportedOperationException is thrown on invocation of the corresponding access mode method.

Annotations
@Override
withInvokeBehaviorback to summary
public VarHandle withInvokeBehavior()

Implements abstract java.lang.invoke.VarHandle.withInvokeBehavior.

Doc from java.lang.invoke.VarHandle.withInvokeBehavior.

Returns a VarHandle, with access to the same variable(s) as this VarHandle, but whose invocation behavior of access mode methods is adjusted to invoke behavior.

If this VarHandle already has invoke behavior this VarHandle is returned.

Invoking hasInvokeExactBehavior() on the returned var handle is guaranteed to return false.

Annotations
@Override
withInvokeExactBehaviorback to summary
public VarHandle withInvokeExactBehavior()

Implements abstract java.lang.invoke.VarHandle.withInvokeExactBehavior.

Doc from java.lang.invoke.VarHandle.withInvokeExactBehavior.

Returns a VarHandle, with access to the same variable(s) as this VarHandle, but whose invocation behavior of access mode methods is adjusted to invoke-exact behavior.

If this VarHandle already has invoke-exact behavior this VarHandle is returned.

Invoking hasInvokeExactBehavior() on the returned var handle is guaranteed to return true.

Annotations
@Override