java.lang.Object
jdk.dynalink.SecureLookupSupplier
jdk.dynalink.CallSiteDescriptor
Call site descriptors contain all the information necessary for linking a
call site. This information is normally passed as parameters to bootstrap
methods and consists of the
MethodHandles.Lookup
object on the caller
class in which the call site occurs, the dynamic operation at the call
site, and the method type of the call site. CallSiteDescriptor
objects are used in Dynalink to capture and store these parameters for
subsequent use by the DynamicLinker
.
The constructors of built-in RelinkableCallSite
implementations all
take a call site descriptor.
Call site descriptors must be immutable. You can use this class as-is or you can subclass it, especially if you need to add further information to the descriptors (typically, values passed in additional parameters to the bootstrap method. Since the descriptors must be immutable, you can set up a cache for equivalent descriptors to have the call sites share them.
The class extends SecureLookupSupplier
for security-checked access to
the MethodHandles.Lookup
object it carries. This lookup should be used
to find method handles to set as targets of the call site described by this
descriptor.
-
Field Summary
Fields declared in class jdk.dynalink.SecureLookupSupplier
GET_LOOKUP_PERMISSION_NAME
-
Constructor Summary
ConstructorDescriptionCallSiteDescriptor
(MethodHandles.Lookup lookup, Operation operation, MethodType methodType) Creates a new call site descriptor. -
Method Summary
Modifier and TypeMethodDescriptionfinal CallSiteDescriptor
changeMethodType
(MethodType newMethodType) Finds or creates a call site descriptor that only differs in its method type from this descriptor.protected CallSiteDescriptor
changeMethodTypeInternal
(MethodType newMethodType) Finds or creates a call site descriptor that only differs in its method type from this descriptor.final CallSiteDescriptor
changeOperation
(Operation newOperation) Finds or creates a call site descriptor that only differs in its operation from this descriptor.protected CallSiteDescriptor
changeOperationInternal
(Operation newOperation) Finds or creates a call site descriptor that only differs in its operation from this descriptor.boolean
Returns true if this call site descriptor is equal to the passed object.final MethodType
The type of the method at the call site.final Operation
Returns the operation at the call site.int
hashCode()
Returns a value-based hash code of this call site descriptor computed from its operation, method type, and lookup object's lookup class and lookup modes.toString()
Returns the string representation of this call site descriptor, of the formatname(parameterTypes)returnType@lookup
.Methods declared in class jdk.dynalink.SecureLookupSupplier
getLookup, getLookupPrivileged
-
Constructor Details
-
CallSiteDescriptor
Creates a new call site descriptor.- Parameters:
lookup
- the lookup object describing the class the call site belongs to. When creating descriptors from ajava.lang.invoke
bootstrap method, it should be the lookup passed to the bootstrap.operation
- the dynamic operation at the call site.methodType
- the method type of the call site. When creating descriptors from ajava.lang.invoke
bootstrap method, it should be the method type passed to the bootstrap.
-
-
Method Details
-
getOperation
Returns the operation at the call site.- Returns:
- the operation at the call site.
-
getMethodType
The type of the method at the call site.- Returns:
- type of the method at the call site.
-
changeMethodType
Finds or creates a call site descriptor that only differs in its method type from this descriptor. InvokeschangeMethodTypeInternal(MethodType)
.- Parameters:
newMethodType
- the new method type- Returns:
- a call site descriptor with changed method type.
- Throws:
NullPointerException
- ifnewMethodType
is null.
-
changeMethodTypeInternal
Finds or creates a call site descriptor that only differs in its method type from this descriptor. Subclasses must override this method to return an object of their exact class. If an overridden method changes something other than the method type in the descriptor (its class, lookup, or operation), or returns null, anAssertionError
will be thrown fromchangeMethodType(MethodType)
.- Parameters:
newMethodType
- the new method type- Returns:
- a call site descriptor with the changed method type.
-
changeOperation
Finds or creates a call site descriptor that only differs in its operation from this descriptor. InvokeschangeOperationInternal(Operation)
.- Parameters:
newOperation
- the new operation- Returns:
- a call site descriptor with the changed operation.
- Throws:
NullPointerException
- ifnewOperation
is null.SecurityException
- if the descriptor's lookup isn't theMethodHandles.publicLookup()
, and a security manager is present, and a check forRuntimePermission("dynalink.getLookup")
fails. This is necessary as changing the operation in the call site descriptor allows fabrication of descriptors for arbitrary operations with the lookup.
-
changeOperationInternal
Finds or creates a call site descriptor that only differs in its operation from this descriptor. Subclasses must override this method to return an object of their exact class. If an overridden method changes something other than the operation in the descriptor (its class, lookup, or method type), or returns null, anAssertionError
will be thrown fromchangeOperation(Operation)
.- Parameters:
newOperation
- the new operation- Returns:
- a call site descriptor with the changed operation.
-
equals
Returns true if this call site descriptor is equal to the passed object. It is considered equal if the other object is of the exact same class, their operations and method types are equal, and their lookups have the sameMethodHandles.Lookup.lookupClass()
andMethodHandles.Lookup.lookupModes()
. -
hashCode
public int hashCode()Returns a value-based hash code of this call site descriptor computed from its operation, method type, and lookup object's lookup class and lookup modes. -
toString
Returns the string representation of this call site descriptor, of the formatname(parameterTypes)returnType@lookup
.
-