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

pack-priv abstract Class AbstractJavaLinker

extends Object
implements GuardingDynamicLinker
Class Inheritance
All Implemented Interfaces
jdk.dynalink.linker.GuardingDynamicLinker
Known Direct Subclasses
jdk.dynalink.beans.BeanLinker, jdk.dynalink.beans.StaticClassLinker.SingleClassStaticsLinker
Imports
java.lang.invoke.MethodHandle, .MethodHandles, .MethodType, java.lang.reflect.Constructor, .Executable, .Field, .Method, .Modifier, java.util.Arrays, .Collections, .HashMap, .List, .Map, .Set, jdk.dynalink.CallSiteDescriptor, .NamedOperation, .Namespace, .NamespaceOperation, .Operation, .StandardNamespace, .StandardOperation, jdk.dynalink.beans.GuardedInvocationComponent.ValidationType, jdk.dynalink.internal.InternalTypeUtilities, jdk.dynalink.linker.GuardedInvocation, .GuardingDynamicLinker, .LinkRequest, .LinkerServices, jdk.dynalink.linker.support.Guards, .Lookup, jdk.internal.reflect.CallerSensitive

A base class for both StaticClassLinker and BeanLinker. Deals with common aspects of property exposure and method calls for both static and instance facets of a class.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
private final MethodHandle
private final MethodHandle
pack-priv final Class<?>
private static final MethodHandle
private static final MethodHandle
private static final MethodHandle
private static final MethodHandle
private static final MethodHandle
private static final MethodHandle
private final MethodHandle
private final MethodHandle
private final MethodHandle
private static final MethodHandle
private static final MethodHandle
private static final MethodHandle
private static final MethodHandle
private final Map<String, DynamicMethod>
private static final MethodHandle
private static final Lookup
private final Map<String, AbstractJavaLinker.AnnotatedDynamicMethod>
private final Map<String, DynamicMethod>

Constructor Summary

AccessConstructor and Description
pack-priv
AbstractJavaLinker(final Class<?> clazz, final MethodHandle classGuard)

pack-priv
AbstractJavaLinker(final Class<?> clazz, final MethodHandle classGuard, final MethodHandle assignableGuard)

Method Summary

Modifier and TypeMethod and Description
private void
addMember(final String name, final Executable m, final Map<String, DynamicMethod> methodMap)

private void
addMember(final String name, final SingleDynamicMethod method, final Map<String, DynamicMethod> methodMap)

private static void
assertParameterCount(final CallSiteDescriptor descriptor, final int paramCount)

pack-priv static DynamicMethod

Returns:

a dynamic method representing all the specified reflective members.
createDynamicMethod
(final Iterable<? extends Executable>
the reflective members
members
,
final Class<?>
the class declaring the reflective members
clazz
,
final String
the common name of the reflective members.
name
)

Given one or more reflective methods or constructors, creates a dynamic method that represents them all.

private static SingleDynamicMethod

Returns:

the single dynamic method representing the reflective member
createDynamicMethod
(final Executable
the reflective member
m
)

Given a reflective method or a constructor, creates a dynamic method that represents it.

pack-priv abstract FacetIntrospector
private GuardedInvocation
createGuardedDynamicMethodInvocation(final CallSiteDescriptor callSiteDescriptor, final LinkerServices linkerServices, final String methodName, final Map<String, DynamicMethod> methodMap)

private GuardedInvocationComponent
createNoSuchMemberHandler(final MissingMemberHandlerFactory missingMemberHandlerFactory, final LinkRequest linkRequest, final LinkerServices linkerServices)

private static String
decapitalize(final String str)

private MethodHandle
pack-priv MethodHandle
pack-priv GuardedInvocationComponent
pack-priv abstract SingleDynamicMethod
getConstructorMethod(final String signature)

private DynamicMethod
getDynamicMethod(final String methodName, final Map<String, DynamicMethod> methodMap)

private Object
pack-priv DynamicMethod

Returns:

the dynamic method (either SimpleDynamicMethod or OverloadedDynamicMethod, or null if the method with the specified name does not exist.
getDynamicMethod
(final String
name of the method
name
)

Returns a dynamic method of the specified name.

private MethodHandle
getDynamicMethodInvocation(final CallSiteDescriptor callSiteDescriptor, final LinkerServices linkerServices, final String methodName, final Map<String, DynamicMethod> methodMap)

private SingleDynamicMethod
getExplicitSignatureDynamicMethod(final String fullName, final Map<String, DynamicMethod> methodsMap)

private MethodHandle
getGuard(final GuardedInvocationComponent.ValidationType validationType, final MethodType methodType)

public GuardedInvocation
getGuardedInvocation(final LinkRequest request, 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.

protected GuardedInvocationComponent
private GuardedInvocationComponent
private static MethodType
pack-priv Set<String>
private static Method

Returns:

getter with same name, declared on the most generic superclass/interface of the declaring class
getMostGenericGetter
(final Method
the getter
getter
)

Find the most generic superclass that declares this getter.

private static Method
getMostGenericGetter(final String name, final Class<?> declaringClass)

private GuardedInvocationComponent
private GuardedInvocationComponent
private GuardedInvocationComponent
pack-priv GuardedInvocationComponent
private GuardedInvocationComponent
private Object
getPropertyGetterHandle(final Object
the property ID
id
)

Returns: the method handle for retrieving the property, or null if the property does not exist

private GuardedInvocationComponent
private MethodHandle
getPropertySetterHandle(final CallSiteDescriptor setterDescriptor, final LinkerServices linkerServices, final Object id)

pack-priv Set<String>
private static Set<String>
private GuardedInvocationComponent
private GuardedInvocationComponent
private GuardedInvocationComponent
pack-priv Set<String>
pack-priv static AbstractJavaLinker.MethodPair
private static DynamicMethod
mergeMethods(final SingleDynamicMethod method, final DynamicMethod existing, final Class<?> clazz, final String name)

private void
setPropertyGetter(final String
name of the property
name
,
final SingleDynamicMethod
the method handle that implements the property getter
handle
,
final GuardedInvocationComponent.ValidationType
the validation type for the property
validationType
)

Sets the specified dynamic method to be the property getter for the specified property.

private void
setPropertyGetter(final Method
the getter method
getter
,
final int
the getter prefix in the method name; should be 3 for getter names starting with "get" and 2 for names starting with "is".
prefixLen
)

Sets the specified reflective method to be the property getter for the specified property.

pack-priv void
setPropertyGetter(final String
name of the property
name
,
final MethodHandle
the method handle that implements the property getter
handle
,
final GuardedInvocationComponent.ValidationType
the validation type for the property
validationType
)

Sets the specified method handle to be the property getter for the specified property.

private static MethodHandle

Returns:

the method handle
unreflectSafely
(final Executable
the method or constructor
m
)

Unreflects a method handle from a Method or a Constructor using safe (zero-privilege) unreflection.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

assignableGuardback to summary
private final MethodHandle assignableGuard
classGuardback to summary
private final MethodHandle classGuard
clazzback to summary
pack-priv final Class<?> clazz
CONSTANT_NULL_DROP_ANNOTATED_METHODback to summary
private static final MethodHandle CONSTANT_NULL_DROP_ANNOTATED_METHOD
CONSTANT_NULL_DROP_METHOD_HANDLEback to summary
private static final MethodHandle CONSTANT_NULL_DROP_METHOD_HANDLE
GET_ANNOTATED_METHODback to summary
private static final MethodHandle GET_ANNOTATED_METHOD
GET_DYNAMIC_METHODback to summary
private static final MethodHandle GET_DYNAMIC_METHOD
GET_PROPERTY_GETTER_HANDLEback to summary
private static final MethodHandle GET_PROPERTY_GETTER_HANDLE
GET_PROPERTY_SETTER_HANDLEback to summary
private static final MethodHandle GET_PROPERTY_SETTER_HANDLE
getDynamicMethodback to summary
private final MethodHandle getDynamicMethod
getPropertyGetterHandleback to summary
private final MethodHandle getPropertyGetterHandle
getPropertySetterHandleback to summary
private final MethodHandle getPropertySetterHandle
GETTER_INVOKERback to summary
private static final MethodHandle GETTER_INVOKER
IS_ANNOTATED_METHOD_NOT_NULLback to summary
private static final MethodHandle IS_ANNOTATED_METHOD_NOT_NULL
IS_DYNAMIC_METHODback to summary
private static final MethodHandle IS_DYNAMIC_METHOD
IS_METHOD_HANDLE_NOT_NULLback to summary
private static final MethodHandle IS_METHOD_HANDLE_NOT_NULL
methodsback to summary
private final Map<String, DynamicMethod> methods
OBJECT_IDENTITYback to summary
private static final MethodHandle OBJECT_IDENTITY
privateLookupback to summary
private static final Lookup privateLookup
propertyGettersback to summary
private final Map<String, AbstractJavaLinker.AnnotatedDynamicMethod> propertyGetters
propertySettersback to summary
private final Map<String, DynamicMethod> propertySetters

Constructor Detail

AbstractJavaLinkerback to summary
pack-priv AbstractJavaLinker(final Class<?> clazz, final MethodHandle classGuard)
AbstractJavaLinkerback to summary
pack-priv AbstractJavaLinker(final Class<?> clazz, final MethodHandle classGuard, final MethodHandle assignableGuard)

Method Detail

addMemberback to summary
private void addMember(final String name, final Executable m, final Map<String, DynamicMethod> methodMap)
addMemberback to summary
private void addMember(final String name, final SingleDynamicMethod method, final Map<String, DynamicMethod> methodMap)
assertParameterCountback to summary
private static void assertParameterCount(final CallSiteDescriptor descriptor, final int paramCount)
createDynamicMethodback to summary
pack-priv static DynamicMethod createDynamicMethod(final Iterable<? extends Executable> members, final Class<?> clazz, final String name)

Given one or more reflective methods or constructors, creates a dynamic method that represents them all. The methods should represent all overloads of the same name (or all constructors of the class).

Parameters
members:Iterable<? extends Executable>

the reflective members

clazz:Class<?>

the class declaring the reflective members

name:String

the common name of the reflective members.

Returns:DynamicMethod

a dynamic method representing all the specified reflective members.

createDynamicMethodback to summary
private static SingleDynamicMethod createDynamicMethod(final Executable m)

Given a reflective method or a constructor, creates a dynamic method that represents it. This method will distinguish between caller sensitive and ordinary methods/constructors, and create appropriate caller sensitive dynamic method when needed.

Parameters
m:Executable

the reflective member

Returns:SingleDynamicMethod

the single dynamic method representing the reflective member

createFacetIntrospectorback to summary
pack-priv abstract FacetIntrospector createFacetIntrospector()
createGuardedDynamicMethodInvocationback to summary
private GuardedInvocation createGuardedDynamicMethodInvocation(final CallSiteDescriptor callSiteDescriptor, final LinkerServices linkerServices, final String methodName, final Map<String, DynamicMethod> methodMap)
createNoSuchMemberHandlerback to summary
private GuardedInvocationComponent createNoSuchMemberHandler(final MissingMemberHandlerFactory missingMemberHandlerFactory, final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception
decapitalizeback to summary
private static String decapitalize(final String str)
getAssignableGuardback to summary
private MethodHandle getAssignableGuard(final MethodType type)
getClassGuardback to summary
pack-priv MethodHandle getClassGuard(final MethodType type)
getClassGuardedInvocationComponentback to summary
pack-priv GuardedInvocationComponent getClassGuardedInvocationComponent(final MethodHandle invocation, final MethodType type)
getConstructorMethodback to summary
pack-priv abstract SingleDynamicMethod getConstructorMethod(final String signature)
getDynamicMethodback to summary
private DynamicMethod getDynamicMethod(final String methodName, final Map<String, DynamicMethod> methodMap)
getDynamicMethodback to summary
private Object getDynamicMethod(final Object name)
Annotations
@SuppressWarnings:unused
getDynamicMethodback to summary
pack-priv DynamicMethod getDynamicMethod(final String name)

Returns a dynamic method of the specified name.

Parameters
name:String

name of the method

Returns:DynamicMethod

the dynamic method (either SimpleDynamicMethod or OverloadedDynamicMethod, or null if the method with the specified name does not exist.

getDynamicMethodInvocationback to summary
private MethodHandle getDynamicMethodInvocation(final CallSiteDescriptor callSiteDescriptor, final LinkerServices linkerServices, final String methodName, final Map<String, DynamicMethod> methodMap)
getExplicitSignatureDynamicMethodback to summary
private SingleDynamicMethod getExplicitSignatureDynamicMethod(final String fullName, final Map<String, DynamicMethod> methodsMap)
getGuardback to summary
private MethodHandle getGuard(final GuardedInvocationComponent.ValidationType validationType, final MethodType methodType)
getGuardedInvocationback to summary
public GuardedInvocation getGuardedInvocation(final LinkRequest request, 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
getGuardedInvocationComponentback to summary
protected GuardedInvocationComponent getGuardedInvocationComponent(final AbstractJavaLinker.ComponentLinkRequest req) throws Exception
getMethodGetterback to summary
private GuardedInvocationComponent getMethodGetter(final AbstractJavaLinker.ComponentLinkRequest req) throws Exception
getMethodGetterTypeback to summary
private static MethodType getMethodGetterType(final AbstractJavaLinker.ComponentLinkRequest req)
getMethodNamesback to summary
pack-priv Set<String> getMethodNames()
getMostGenericGetterback to summary
private static Method getMostGenericGetter(final Method getter)

Find the most generic superclass that declares this getter. Since getters have zero args (aside from the receiver), they can't be overloaded, so we're free to link with an instanceof guard for the most generic one, creating more stable call sites.

Parameters
getter:Method

the getter

Returns:Method

getter with same name, declared on the most generic superclass/interface of the declaring class

getMostGenericGetterback to summary
private static Method getMostGenericGetter(final String name, final Class<?> declaringClass)
getNamedMethodGetterback to summary
private GuardedInvocationComponent getNamedMethodGetter(final AbstractJavaLinker.ComponentLinkRequest req) throws Exception
getNamedPropertyGetterback to summary
private GuardedInvocationComponent getNamedPropertyGetter(final AbstractJavaLinker.ComponentLinkRequest req) throws Exception
getNamedPropertySetterback to summary
private GuardedInvocationComponent getNamedPropertySetter(final AbstractJavaLinker.ComponentLinkRequest req) throws Exception
getNextComponentback to summary
pack-priv GuardedInvocationComponent getNextComponent(final AbstractJavaLinker.ComponentLinkRequest req) throws Exception
getPropertyGetterback to summary
private GuardedInvocationComponent getPropertyGetter(final AbstractJavaLinker.ComponentLinkRequest req) throws Exception
getPropertyGetterHandleback to summary
private Object getPropertyGetterHandle(final Object id)
Parameters
id:Object

the property ID

Returns:Object

the method handle for retrieving the property, or null if the property does not exist

Annotations
@SuppressWarnings:unused
getPropertySetterback to summary
private GuardedInvocationComponent getPropertySetter(final AbstractJavaLinker.ComponentLinkRequest req) throws Exception
getPropertySetterHandleback to summary
private MethodHandle getPropertySetterHandle(final CallSiteDescriptor setterDescriptor, final LinkerServices linkerServices, final Object id)
Annotations
@SuppressWarnings:unused
getReadablePropertyNamesback to summary
pack-priv Set<String> getReadablePropertyNames()
getUnmodifiableKeysback to summary
private static Set<String> getUnmodifiableKeys(final Map<String, ?> m)
getUnnamedMethodGetterback to summary
private GuardedInvocationComponent getUnnamedMethodGetter(final AbstractJavaLinker.ComponentLinkRequest req) throws Exception
getUnnamedPropertyGetterback to summary
private GuardedInvocationComponent getUnnamedPropertyGetter(final AbstractJavaLinker.ComponentLinkRequest req) throws Exception
getUnnamedPropertySetterback to summary
private GuardedInvocationComponent getUnnamedPropertySetter(final AbstractJavaLinker.ComponentLinkRequest req) throws Exception
getWritablePropertyNamesback to summary
pack-priv Set<String> getWritablePropertyNames()
matchReturnTypesback to summary
pack-priv static AbstractJavaLinker.MethodPair matchReturnTypes(final MethodHandle m1, final MethodHandle m2)
mergeMethodsback to summary
private static DynamicMethod mergeMethods(final SingleDynamicMethod method, final DynamicMethod existing, final Class<?> clazz, final String name)
setPropertyGetterback to summary
private void setPropertyGetter(final String name, final SingleDynamicMethod handle, final GuardedInvocationComponent.ValidationType validationType)

Sets the specified dynamic method to be the property getter for the specified property. Note that you can only use this when you're certain that the method handle does not belong to a caller-sensitive method. For properties that are caller-sensitive, you must use setPropertyGetter(String, SingleDynamicMethod, ValidationType) instead.

Parameters
name:String

name of the property

handle:SingleDynamicMethod

the method handle that implements the property getter

validationType:GuardedInvocationComponent.ValidationType

the validation type for the property

setPropertyGetterback to summary
private void setPropertyGetter(final Method getter, final int prefixLen)

Sets the specified reflective method to be the property getter for the specified property.

Parameters
getter:Method

the getter method

prefixLen:int

the getter prefix in the method name; should be 3 for getter names starting with "get" and 2 for names starting with "is".

setPropertyGetterback to summary
pack-priv void setPropertyGetter(final String name, final MethodHandle handle, final GuardedInvocationComponent.ValidationType validationType)

Sets the specified method handle to be the property getter for the specified property. Note that you can only use this when you're certain that the method handle does not belong to a caller-sensitive method. For properties that are caller-sensitive, you must use setPropertyGetter(String, SingleDynamicMethod, ValidationType) instead.

Parameters
name:String

name of the property

handle:MethodHandle

the method handle that implements the property getter

validationType:GuardedInvocationComponent.ValidationType

the validation type for the property

unreflectSafelyback to summary
private static MethodHandle unreflectSafely(final Executable m)

Unreflects a method handle from a Method or a Constructor using safe (zero-privilege) unreflection. Should be only used for methods and constructors that are not caller sensitive. If a caller sensitive method were unreflected through this mechanism, it would not be a security issue, but would be bound to the zero-privilege unreflector as its caller, and thus completely useless.

Parameters
m:Executable

the method or constructor

Returns:MethodHandle

the method handle

jdk.dynalink.beans back to summary

private final Class AbstractJavaLinker.AnnotatedDynamicMethod

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final SingleDynamicMethod
pack-priv final GuardedInvocationComponent.ValidationType

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv MethodHandle
pack-priv MethodHandle
getTarget(final CallSiteDescriptor desc, final LinkerServices linkerServices)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

methodback to summary
private final SingleDynamicMethod method
validationTypeback to summary
pack-priv final GuardedInvocationComponent.ValidationType validationType

Constructor Detail

AnnotatedDynamicMethodback to summary
pack-priv AnnotatedDynamicMethod(final SingleDynamicMethod method, final GuardedInvocationComponent.ValidationType validationType)

Method Detail

getInvocationback to summary
pack-priv MethodHandle getInvocation(final AbstractJavaLinker.ComponentLinkRequest req)
getTargetback to summary
pack-priv MethodHandle getTarget(final CallSiteDescriptor desc, final LinkerServices linkerServices)
Annotations
@SuppressWarnings:unused
jdk.dynalink.beans back to summary

pack-priv final Class AbstractJavaLinker.ComponentLinkRequest

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final Operation
pack-priv final LinkerServices
pack-priv final LinkRequest
pack-priv final MissingMemberHandlerFactory
pack-priv final Object
pack-priv final List<Namespace>

Constructor Summary

AccessConstructor and Description
pack-priv
ComponentLinkRequest(final LinkRequest linkRequest, final LinkerServices linkerServices, final MissingMemberHandlerFactory missingMemberHandlerFactory)

private
ComponentLinkRequest(final LinkRequest linkRequest, final LinkerServices linkerServices, final MissingMemberHandlerFactory missingMemberHandlerFactory, final Operation baseOperation, final List<Namespace> namespaces, final Object name)

Method Summary

Modifier and TypeMethod and Description
pack-priv CallSiteDescriptor
pack-priv AbstractJavaLinker.ComponentLinkRequest
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

baseOperationback to summary
pack-priv final Operation baseOperation
linkerServicesback to summary
pack-priv final LinkerServices linkerServices
linkRequestback to summary
pack-priv final LinkRequest linkRequest
missingMemberHandlerFactoryback to summary
pack-priv final MissingMemberHandlerFactory missingMemberHandlerFactory
nameback to summary
pack-priv final Object name
namespacesback to summary
pack-priv final List<Namespace> namespaces

Constructor Detail

ComponentLinkRequestback to summary
pack-priv ComponentLinkRequest(final LinkRequest linkRequest, final LinkerServices linkerServices, final MissingMemberHandlerFactory missingMemberHandlerFactory)
ComponentLinkRequestback to summary
private ComponentLinkRequest(final LinkRequest linkRequest, final LinkerServices linkerServices, final MissingMemberHandlerFactory missingMemberHandlerFactory, final Operation baseOperation, final List<Namespace> namespaces, final Object name)

Method Detail

getDescriptorback to summary
pack-priv CallSiteDescriptor getDescriptor()
popNamespaceback to summary
pack-priv AbstractJavaLinker.ComponentLinkRequest popNamespace()
jdk.dynalink.beans back to summary

pack-priv Class AbstractJavaLinker.MethodPair

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final MethodHandle
pack-priv final MethodHandle

Constructor Summary

AccessConstructor and Description
pack-priv
MethodPair(final MethodHandle method1, final MethodHandle method2)

Method Summary

Modifier and TypeMethod and Description
pack-priv MethodHandle
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

method1back to summary
pack-priv final MethodHandle method1
method2back to summary
pack-priv final MethodHandle method2

Constructor Detail

MethodPairback to summary
pack-priv MethodPair(final MethodHandle method1, final MethodHandle method2)

Method Detail

guardWithTestback to summary
pack-priv MethodHandle guardWithTest(final MethodHandle test)