Class CallSiteDescriptor
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.
Field Summary
Fields declared in class jdk.dynalink.SecureLookupSupplier
GET_LOOKUP_PERMISSION_NAME
Constructor Summary
Constructor | Description |
---|---|
CallSiteDescriptor |
Creates a new call site descriptor. |
Method Summary
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 . |
Methods declared in class jdk.dynalink.SecureLookupSupplier
getLookup, getLookupPrivileged
Constructor Details
CallSiteDescriptor
public CallSiteDescriptor(MethodHandles.Lookup lookup, Operation operation, MethodType methodType)
- 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
public final Operation getOperation()
- Returns:
- the operation at the call site.
getMethodType
public final MethodType getMethodType()
- Returns:
- type of the method at the call site.
changeMethodType
public final CallSiteDescriptor changeMethodType(MethodType newMethodType)
changeMethodTypeInternal(MethodType)
.- Parameters:
-
newMethodType
- the new method type - Returns:
- a call site descriptor with changed method type.
- Throws:
-
NullPointerException
- ifnewMethodType
is null.
changeMethodTypeInternal
protected CallSiteDescriptor changeMethodTypeInternal(MethodType newMethodType)
AssertionError
will be thrown from changeMethodType(MethodType)
.- Parameters:
-
newMethodType
- the new method type - Returns:
- a call site descriptor with the changed method type.
changeOperation
public final CallSiteDescriptor changeOperation(Operation newOperation)
changeOperationInternal(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
protected CallSiteDescriptor changeOperationInternal(Operation newOperation)
AssertionError
will be thrown from changeOperation(Operation)
.- Parameters:
-
newOperation
- the new operation - Returns:
- a call site descriptor with the changed operation.
equals
public boolean equals(Object obj)
MethodHandles.Lookup.lookupClass()
and MethodHandles.Lookup.lookupModes()
.hashCode
public int hashCode()
toString
public String toString()
name(parameterTypes)returnType@lookup
.
© 1993, 2021, 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/17/docs/api/jdk.dynalink/jdk/dynalink/CallSiteDescriptor.html