APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.dynalink.linker.support

public Class CompositeTypeBasedGuardingDynamicLinker

extends Object
implements TypeBasedGuardingDynamicLinker
Class Inheritance
All Implemented Interfaces
jdk.dynalink.linker.TypeBasedGuardingDynamicLinker, jdk.dynalink.linker.GuardingDynamicLinker
Imports
java.util.Collections, .LinkedList, .List, .Objects, jdk.dynalink.linker.GuardedInvocation, .GuardingDynamicLinker, .LinkRequest, .LinkerServices, .TypeBasedGuardingDynamicLinker

A composite type-based guarding dynamic linker. When a receiver of a not yet seen class is encountered, all linkers are queried sequentially on their TypeBasedGuardingDynamicLinker#canLinkType(Class) method. The linkers returning true are then bound to the class, and next time a receiver of same type is encountered, the linking is delegated to those linkers only, speeding up dispatch.
Since
9

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final ClassValue<List<TypeBasedGuardingDynamicLinker>>

Constructor Summary

AccessConstructor and Description
public
CompositeTypeBasedGuardingDynamicLinker(final Iterable<? extends TypeBasedGuardingDynamicLinker>
the component linkers
linkers
)

Creates a new composite type-based linker.

Method Summary

Modifier and TypeMethod and Description
private static void
public boolean

Returns:

true true if at least one of the composite linkers returns true from TypeBasedGuardingDynamicLinker#canLinkType(Class), false otherwise.
canLinkType
(final Class<?>
the type to link
type
)

Implements jdk.dynalink.linker.TypeBasedGuardingDynamicLinker.canLinkType.

Returns true if at least one of the composite linkers returns true from TypeBasedGuardingDynamicLinker#canLinkType(Class) for the type.

public GuardedInvocation
getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices)

Implements jdk.dynalink.linker.GuardingDynamicLinker.getGuardedInvocation.

Creates a guarded invocation appropriate for a particular invocation with the specified arguments at a call site.

public static List<GuardingDynamicLinker>

Returns:

the optimized list
optimize
(final Iterable<? extends GuardingDynamicLinker>
the list of linkers to optimize
linkers
)

Optimizes a list of type-based linkers.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

classToLinkerback to summary
private final ClassValue<List<TypeBasedGuardingDynamicLinker>> classToLinker

Constructor Detail

CompositeTypeBasedGuardingDynamicLinkerback to summary
public CompositeTypeBasedGuardingDynamicLinker(final Iterable<? extends TypeBasedGuardingDynamicLinker> linkers)

Creates a new composite type-based linker.

Parameters
linkers:Iterable<? extends TypeBasedGuardingDynamicLinker>

the component linkers

Exceptions
NullPointerException:
if linkers or any of its elements are null.

Method Detail

addTypeBasedback to summary
private static void addTypeBased(final List<GuardingDynamicLinker> llinkers, final List<TypeBasedGuardingDynamicLinker> tblinkers)
canLinkTypeback to summary
public boolean canLinkType(final Class<?> type)

Implements jdk.dynalink.linker.TypeBasedGuardingDynamicLinker.canLinkType.

Returns true if at least one of the composite linkers returns true from TypeBasedGuardingDynamicLinker#canLinkType(Class) for the type.

Parameters
type:Class<?>

the type to link

Returns:boolean

true true if at least one of the composite linkers returns true from TypeBasedGuardingDynamicLinker#canLinkType(Class), false otherwise.

Annotations
@Override
getGuardedInvocationback to summary
public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception

Implements jdk.dynalink.linker.GuardingDynamicLinker.getGuardedInvocation.

Doc from jdk.dynalink.linker.GuardingDynamicLinker.getGuardedInvocation.

Creates a guarded invocation appropriate for a particular invocation with the specified arguments at a call site.

Annotations
@Override
Exceptions
Exception:
if the operation fails for whatever reason
optimizeback to summary
public static List<GuardingDynamicLinker> optimize(final Iterable<? extends GuardingDynamicLinker> linkers)

Optimizes a list of type-based linkers. If a group of adjacent linkers in the list all implement TypeBasedGuardingDynamicLinker, they will be replaced with a single instance of CompositeTypeBasedGuardingDynamicLinker that contains them.

Parameters
linkers:Iterable<? extends GuardingDynamicLinker>

the list of linkers to optimize

Returns:List<GuardingDynamicLinker>

the optimized list

Exceptions
NullPointerException:
if linkers or any of its elements are null.
jdk.dynalink.linker.support back to summary

private Class CompositeTypeBasedGuardingDynamicLinker.ClassToLinker

extends ClassValue<List<TypeBasedGuardingDynamicLinker>>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final TypeBasedGuardingDynamicLinker[]
private static final List<TypeBasedGuardingDynamicLinker>
private final List<TypeBasedGuardingDynamicLinker>[]

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected List<TypeBasedGuardingDynamicLinker>
computeValue(final Class<?> clazz)

Implements abstract java.lang.ClassValue.computeValue.

Computes the value to associate to the given Class.

Inherited from java.lang.ClassValue:
getremove

Field Detail

linkersback to summary
private final TypeBasedGuardingDynamicLinker[] linkers
NO_LINKERback to summary
private static final List<TypeBasedGuardingDynamicLinker> NO_LINKER
singletonLinkersback to summary
private final List<TypeBasedGuardingDynamicLinker>[] singletonLinkers

Constructor Detail

ClassToLinkerback to summary
pack-priv ClassToLinker(final TypeBasedGuardingDynamicLinker[] linkers)
Annotations
@SuppressWarnings:unchecked, rawtypes

Method Detail

computeValueback to summary
protected List<TypeBasedGuardingDynamicLinker> computeValue(final Class<?> clazz)

Implements abstract java.lang.ClassValue.computeValue.

Doc from java.lang.ClassValue.computeValue.

Computes the value to associate to the given Class.

This method is invoked when the initial read-only access by get finds no associated value.

If this method throws an exception, the initiating get call will not attempt to associate a value, and may terminate by returning the associated value if it exists, or by propagating that exception otherwise.

Otherwise, the value is computed and returned. An attempt to associate the return value happens, with one of the following outcomes:

  • The associated value is present; it is returned and no association is done.
  • The most recent remove call, if it exists, does not happen-before (JLS 17.4.5) the finish of the computeValue that computed the value to associate. A new invocation to computeValue, which that remove call happens-before, will re-establish this happens-before relationship.
  • Otherwise, this value is successfully associated and returned.
Annotations
@SuppressWarnings:fallthrough
@Override