DynamicLinkerFactory so it is given the chance to link
calls to all objects that no other linker recognized. Specifically, this
linker will:
record, expose all public accessors of
record components as property getters for StandardOperation#GET operations
in the StandardNamespace#PROPERTY namespace;setXxx(), getXxx(),
and isXxx() as property setters and getters for
StandardOperation#SET and StandardOperation#GET operations in the
StandardNamespace#PROPERTY namespace, except for getters for properties
with names already handled by record component getters;StandardOperation#GET operation in the StandardNamespace#METHOD namespace;
the methods thus retrieved can then be invoked using StandardOperation#CALL.java.util.List and java.util.Map objects as
StandardOperation#GET and StandardOperation#SET operations in the
StandardNamespace#ELEMENT namespace;java.util.List and java.util.Map objects as
StandardOperation#REMOVE operation in the StandardNamespace#ELEMENT namespace;length on Java arrays, java.util.Collection and
java.util.Map objects;StandardOperation#NEW on instances of StaticClass
as calls to constructors, including those static class objects that represent
Java arrays (their constructors take a single int parameter
representing the length of the array to create);StaticClass objects.static on instances of
java.lang.Class to access their StaticClass.Overloaded method resolution is performed automatically
for property setters, methods, and constructors. Additionally, manual
overloaded method selection is supported by having a call site specify a name
for a method that contains an explicit signature, e.g.
StandardOperation.GET.withNamespace(METHOD).named("parseInt(String,int)")
You can use non-qualified class names in such signatures regardless of those
classes' packages, they will match any class with the same non-qualified name. You
only have to use a fully qualified class name in case non-qualified class
names would cause selection ambiguity (that is extremely rare). Overloaded
resolution for constructors is not automatic as there is no logical place to
attach that functionality to but if a language wishes to provide this
functionality, it can use getConstructorMethod(Class, String) as a
useful building block for it.
Variable argument invocation is handled for both methods and constructors.
Caller sensitive methods can be linked as long as they
are otherwise public and link requests have call site descriptors carrying
full-strength Lookup objects and not weakened lookups or the public
lookup.
The behavior for handling missing members can be
customized by passing a MissingMemberHandlerFactory to the
constructor.
The class also exposes various methods for discovery of available
property and method names on classes and class instances, as well as access
to per-class linkers using the getLinkerForClass(Class)
method.
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private static final ClassValue | |
| private final MissingMemberHandlerFactory |
| Access | Constructor and Description |
|---|---|
| public | |
| public | BeansLinker(final MissingMemberHandlerFactory
a factory for creating handlers for
operations on missing members. missingMemberHandlerFactory)Creates a new beans linker with the specified factory for creating missing member handlers. |
| Modifier and Type | Method and Description |
|---|---|
| public static Object | Returns: dynamic method for the constructor or null if no constructor with the specified signature exists.the class clazz, final String full signature of the constructor. Note how you can use
names of primitive types, array names with normal Java notation (e.g.
signature)"int[]"), and normally you can even use unqualified class names
(e.g. "String, List" instead of
"java.lang.String, java.util.List" as long as they don't cause
ambiguity in the specific parameter position.Return the dynamic method of constructor of the given class and the given signature. |
| public GuardedInvocation | getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices)
Implements jdk. Creates a guarded invocation appropriate for a particular invocation with the specified arguments at a call site. |
| public static Set | Returns: a set of names of all instance methods of a class.the class clazz)Returns a set of names of all instance methods of a class. |
| public TypeBasedGuardingDynamicLinker | Returns: a bean linker for that classthe class clazz)Returns a bean linker for a particular single class. |
| public static Set | Returns: a set of names of all readable instance properties of a class.the class clazz)Returns a set of names of all readable instance properties of a class. |
| public static Set | Returns: a set of names of all readable static properties of a class.the class clazz)Returns a set of names of all readable static properties of a class. |
| pack-priv static TypeBasedGuardingDynamicLinker | |
| public static Set | Returns: a set of names of all static methods of a class.the class clazz)Returns a set of names of all static methods of a class. |
| public static Set | Returns: a set of names of all writable instance properties of a class.the class clazz)Returns a set of names of all writable instance properties of a class. |
| public static Set | Returns: a set of names of all writable static properties of a class.the class clazz)Returns a set of names of all writable static properties of a class. |
| public static boolean | Returns: true if it is a constructor, false otherwise.the object we want to test for being a Java constructor. obj)Returns true if the object is a Java constructor (obtained through
|
| public static boolean | Returns: true if it is a dynamic method, false otherwise.the object we want to test for being a Java dynamic method. obj)Returns true if the object is a Java dynamic method (e.g., one
obtained through a |
| linkers | back to summary |
|---|---|
| private static final ClassValue<TypeBasedGuardingDynamicLinker> linkers | |
| missingMemberHandlerFactory | back to summary |
|---|---|
| private final MissingMemberHandlerFactory missingMemberHandlerFactory | |
| BeansLinker | back to summary |
|---|---|
| public BeansLinker() Creates a new beans linker. Equivalent to
| |
| BeansLinker | back to summary |
|---|---|
| public BeansLinker(final MissingMemberHandlerFactory missingMemberHandlerFactory) Creates a new beans linker with the specified factory for creating
missing member handlers. The passed factory can be null if the default
behavior is adequate. See
| |
| getConstructorMethod | back to summary |
|---|---|
| public static Object getConstructorMethod(final Class<?> clazz, final String signature) Return the dynamic method of constructor of the given class and the given
signature. This method is useful for exposing a functionality for
selecting an overloaded constructor based on an explicit signature, as
this functionality is not otherwise exposed by Dynalink as
| |
| getGuardedInvocation | back to summary |
|---|---|
| public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices) throws Exception Implements jdk. Doc from jdk. Creates a guarded invocation appropriate for a particular invocation with the specified arguments at a call site. | |
| getInstanceMethodNames | back to summary |
|---|---|
| public static Set Returns a set of names of all instance methods of a class. | |
| getLinkerForClass | back to summary |
|---|---|
| public TypeBasedGuardingDynamicLinker getLinkerForClass(final Class<?> clazz) Returns a bean linker for a particular single class. Useful when you need to override or extend the behavior of linking for some classes in your language runtime's linker, but still want to delegate to the default behavior in some cases.
| |
| getReadableInstancePropertyNames | back to summary |
|---|---|
| public static Set Returns a set of names of all readable instance properties of a class. | |
| getReadableStaticPropertyNames | back to summary |
|---|---|
| public static Set Returns a set of names of all readable static properties of a class. | |
| getStaticLinkerForClass | back to summary |
|---|---|
| pack-priv static TypeBasedGuardingDynamicLinker getStaticLinkerForClass(final Class<?> clazz) | |
| getStaticMethodNames | back to summary |
|---|---|
| public static Set Returns a set of names of all static methods of a class. | |
| getWritableInstancePropertyNames | back to summary |
|---|---|
| public static Set Returns a set of names of all writable instance properties of a class. | |
| getWritableStaticPropertyNames | back to summary |
|---|---|
| public static Set Returns a set of names of all writable static properties of a class. | |
| isDynamicConstructor | back to summary |
|---|---|
| public static boolean isDynamicConstructor(final Object obj) Returns true if the object is a Java constructor (obtained through
| |
| isDynamicMethod | back to summary |
|---|---|
| public static boolean isDynamicMethod(final Object obj) Returns true if the object is a Java dynamic method (e.g., one
obtained through a
| |
| Modifier and Type | Field and Description |
|---|---|
| private final TypeBasedGuardingDynamicLinker | |
| private final MissingMemberHandlerFactory |
| Access | Constructor and Description |
|---|---|
| pack-priv | NoSuchMemberHandlerBindingLinker(final TypeBasedGuardingDynamicLinker linker, final MissingMemberHandlerFactory missingMemberHandlerFactory)
|
| Modifier and Type | Method and Description |
|---|---|
| public boolean | canLinkType(final Class<?> type)
Implements jdk. Returns true if the linker can link an invocation where the first argument (receiver) is of the specified type. |
| public GuardedInvocation | getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices)
Implements jdk. Creates a guarded invocation appropriate for a particular invocation with the specified arguments at a call site. |
| linker | back to summary |
|---|---|
| private final TypeBasedGuardingDynamicLinker linker | |
| missingMemberHandlerFactory | back to summary |
|---|---|
| private final MissingMemberHandlerFactory missingMemberHandlerFactory | |
| NoSuchMemberHandlerBindingLinker | back to summary |
|---|---|
| pack-priv NoSuchMemberHandlerBindingLinker(final TypeBasedGuardingDynamicLinker linker, final MissingMemberHandlerFactory missingMemberHandlerFactory) | |
| canLinkType | back to summary |
|---|---|
| public boolean canLinkType(final Class<?> type) Implements jdk. Doc from jdk. Returns true if the linker can link an invocation where the first argument (receiver) is of the specified type.
| |
| getGuardedInvocation | back to summary |
|---|---|
| public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception Implements jdk. Doc from jdk. Creates a guarded invocation appropriate for a particular invocation with the specified arguments at a call site. | |