Module jdk.dynalink
Package jdk.dynalink.linker.support
Class CompositeTypeBasedGuardingDynamicLinker
- java.lang.Object
-
- jdk.dynalink.linker.support.CompositeTypeBasedGuardingDynamicLinker
-
- All Implemented Interfaces:
GuardingDynamicLinker
,TypeBasedGuardingDynamicLinker
public class CompositeTypeBasedGuardingDynamicLinker extends Object implements 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 theirTypeBasedGuardingDynamicLinker.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.
-
-
Constructor Summary
Constructors Constructor Description CompositeTypeBasedGuardingDynamicLinker(Iterable<? extends TypeBasedGuardingDynamicLinker> linkers)
Creates a new composite type-based linker.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canLinkType(Class<?> type)
Returns true if at least one of the composite linkers returns true fromTypeBasedGuardingDynamicLinker.canLinkType(Class)
for the type.static List<GuardingDynamicLinker>
optimize(Iterable<? extends GuardingDynamicLinker> linkers)
Optimizes a list of type-based linkers.-
Methods declared in interface jdk.dynalink.linker.GuardingDynamicLinker
getGuardedInvocation
-
-
-
-
Constructor Detail
-
CompositeTypeBasedGuardingDynamicLinker
public CompositeTypeBasedGuardingDynamicLinker(Iterable<? extends TypeBasedGuardingDynamicLinker> linkers)
Creates a new composite type-based linker.- Parameters:
linkers
- the component linkers- Throws:
NullPointerException
- iflinkers
or any of its elements are null.
-
-
Method Detail
-
canLinkType
public boolean canLinkType(Class<?> type)
Returns true if at least one of the composite linkers returns true fromTypeBasedGuardingDynamicLinker.canLinkType(Class)
for the type.- Specified by:
canLinkType
in interfaceTypeBasedGuardingDynamicLinker
- Parameters:
type
- the type to link- Returns:
- true true if at least one of the composite linkers returns true
from
TypeBasedGuardingDynamicLinker.canLinkType(Class)
, false otherwise.
-
optimize
public static List<GuardingDynamicLinker> optimize(Iterable<? extends GuardingDynamicLinker> linkers)
Optimizes a list of type-based linkers. If a group of adjacent linkers in the list all implementTypeBasedGuardingDynamicLinker
, they will be replaced with a single instance ofCompositeTypeBasedGuardingDynamicLinker
that contains them.- Parameters:
linkers
- the list of linkers to optimize- Returns:
- the optimized list
- Throws:
NullPointerException
- iflinkers
or any of its elements are null.
-
-