public class CallSiteDescriptor extends SecureLookupSupplier
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.
GET_LOOKUP_PERMISSION_NAME
Constructor | Description |
---|---|
CallSiteDescriptor |
Creates a new call site descriptor. |
Modifier and Type | Method | Description |
---|---|---|
final CallSiteDescriptor |
changeMethodType |
Finds or creates a call site descriptor that only differs in its method type from this descriptor. |
protected CallSiteDescriptor |
changeMethodTypeInternal |
Finds or creates a call site descriptor that only differs in its method type from this descriptor. |
final CallSiteDescriptor |
changeOperation |
Finds or creates a call site descriptor that only differs in its operation from this descriptor. |
protected CallSiteDescriptor |
changeOperationInternal |
Finds or creates a call site descriptor that only differs in its operation from this descriptor. |
boolean |
equals |
Returns true if this call site descriptor is equal to the passed object. |
final MethodType |
getMethodType() |
The type of the method at the call site. |
final Operation |
getOperation() |
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. |
String |
toString() |
Returns the string representation of this call site descriptor, of the format name(parameterTypes)returnType@lookup . |
getLookup, getLookupPrivileged
public CallSiteDescriptor(MethodHandles.Lookup lookup, Operation operation, MethodType methodType)
lookup
- the lookup object describing the class the call site belongs to. When creating descriptors from a java.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 a java.lang.invoke
bootstrap method, it should be the method type passed to the bootstrap.public final Operation getOperation()
public final MethodType getMethodType()
public final CallSiteDescriptor changeMethodType(MethodType newMethodType)
changeMethodTypeInternal(MethodType)
.newMethodType
- the new method typeNullPointerException
- if newMethodType
is null.protected CallSiteDescriptor changeMethodTypeInternal(MethodType newMethodType)
AssertionError
will be thrown from changeMethodType(MethodType)
.newMethodType
- the new method typepublic final CallSiteDescriptor changeOperation(Operation newOperation)
changeOperationInternal(Operation)
.newOperation
- the new operationNullPointerException
- if newOperation
is null.SecurityException
- if the descriptor's lookup isn't the MethodHandles.publicLookup()
, and a security manager is present, and a check for RuntimePermission("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.protected CallSiteDescriptor changeOperationInternal(Operation newOperation)
AssertionError
will be thrown from changeOperation(Operation)
.newOperation
- the new operationpublic boolean equals(Object obj)
MethodHandles.Lookup.lookupClass()
and MethodHandles.Lookup.lookupModes()
.public int hashCode()
public String toString()
name(parameterTypes)returnType@lookup
.
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/jdk.dynalink/jdk/dynalink/CallSiteDescriptor.html