CallSiteDescriptor (Java SE 11 & JDK 11 ) (original) (raw)
- jdk.dynalink.SecureLookupSupplier
- jdk.dynalink.CallSiteDescriptor
public class CallSiteDescriptor
extends SecureLookupSupplier
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](SecureLookupSupplier.html "class in jdk.dynalink") `[GET_LOOKUP_PERMISSION_NAME](SecureLookupSupplier.html#GET%5FLOOKUP%5FPERMISSION%5FNAME)`
Constructor Summary
Constructors
Constructor Description CallSiteDescriptor(MethodHandles.Lookup lookup,Operation operation,MethodType methodType) Creates a new call site descriptor. Method Summary
All Methods Instance Methods Concrete Methods
Modifier and Type Method Description 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. 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 equals(Object obj) Returns true if this call site descriptor is equal to the passed object. MethodType getMethodType() The type of the method at the call site. 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](SecureLookupSupplier.html "class in jdk.dynalink") `[getLookup](SecureLookupSupplier.html#getLookup%28%29), [getLookupPrivileged](SecureLookupSupplier.html#getLookupPrivileged%28%29)` * ### Methods declared in class java.lang.[Object](../../../java.base/java/lang/Object.html "class in java.lang") `[clone](../../../java.base/java/lang/Object.html#clone%28%29), [finalize](../../../java.base/java/lang/Object.html#finalize%28%29), [getClass](../../../java.base/java/lang/Object.html#getClass%28%29), [notify](../../../java.base/java/lang/Object.html#notify%28%29), [notifyAll](../../../java.base/java/lang/Object.html#notifyAll%28%29), [wait](../../../java.base/java/lang/Object.html#wait%28%29), [wait](../../../java.base/java/lang/Object.html#wait%28long%29), [wait](../../../java.base/java/lang/Object.html#wait%28long,int%29)`
Constructor Detail
* #### CallSiteDescriptor public CallSiteDescriptor([MethodHandles.Lookup](../../../java.base/java/lang/invoke/MethodHandles.Lookup.html "class in java.lang.invoke") lookup, [Operation](Operation.html "interface in jdk.dynalink") operation, [MethodType](../../../java.base/java/lang/invoke/MethodType.html "class in java.lang.invoke") methodType) Creates a new call site descriptor. Parameters: `lookup` \- the lookup object describing the class the call site belongs to. When creating descriptors from a [java.lang.invoke](../../../java.base/java/lang/invoke/package-summary.html) 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](../../../java.base/java/lang/invoke/package-summary.html) bootstrap method, it should be the method type passed to the bootstrap.
Method Detail
* #### getOperation public final [Operation](Operation.html "interface in jdk.dynalink") getOperation() Returns the operation at the call site. Returns: the operation at the call site. * #### getMethodType public final [MethodType](../../../java.base/java/lang/invoke/MethodType.html "class in java.lang.invoke") getMethodType() The type of the method at the call site. Returns: type of the method at the call site. * #### changeMethodType public final [CallSiteDescriptor](CallSiteDescriptor.html "class in jdk.dynalink") changeMethodType([MethodType](../../../java.base/java/lang/invoke/MethodType.html "class in java.lang.invoke") newMethodType) Finds or creates a call site descriptor that only differs in its method type from this descriptor. Invokes [changeMethodTypeInternal(MethodType)](#changeMethodTypeInternal%28java.lang.invoke.MethodType%29). Parameters: `newMethodType` \- the new method type Returns: a call site descriptor with changed method type. Throws: `[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")` \- if `newMethodType` is null. * #### changeMethodTypeInternal protected [CallSiteDescriptor](CallSiteDescriptor.html "class in jdk.dynalink") changeMethodTypeInternal([MethodType](../../../java.base/java/lang/invoke/MethodType.html "class in java.lang.invoke") newMethodType) 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, an `AssertionError` will be thrown from [changeMethodType(MethodType)](#changeMethodType%28java.lang.invoke.MethodType%29). Parameters: `newMethodType` \- the new method type Returns: a call site descriptor with the changed method type. * #### changeOperation public final [CallSiteDescriptor](CallSiteDescriptor.html "class in jdk.dynalink") changeOperation([Operation](Operation.html "interface in jdk.dynalink") newOperation) Finds or creates a call site descriptor that only differs in its operation from this descriptor. Invokes [changeOperationInternal(Operation)](#changeOperationInternal%28jdk.dynalink.Operation%29). Parameters: `newOperation` \- the new operation Returns: a call site descriptor with the changed operation. Throws: `[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")` \- if `newOperation` is null. `[SecurityException](../../../java.base/java/lang/SecurityException.html "class in java.lang")` \- if the descriptor's lookup isn't the[MethodHandles.publicLookup()](../../../java.base/java/lang/invoke/MethodHandles.html#publicLookup%28%29), 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. * #### changeOperationInternal protected [CallSiteDescriptor](CallSiteDescriptor.html "class in jdk.dynalink") changeOperationInternal([Operation](Operation.html "interface in jdk.dynalink") newOperation) 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, an `AssertionError` will be thrown from [changeOperation(Operation)](#changeOperation%28jdk.dynalink.Operation%29). Parameters: `newOperation` \- the new operation Returns: a call site descriptor with the changed operation. * #### equals public boolean equals([Object](../../../java.base/java/lang/Object.html "class in java.lang") obj) 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 same [MethodHandles.Lookup.lookupClass()](../../../java.base/java/lang/invoke/MethodHandles.Lookup.html#lookupClass%28%29) and[MethodHandles.Lookup.lookupModes()](../../../java.base/java/lang/invoke/MethodHandles.Lookup.html#lookupModes%28%29). Overrides: `[equals](../../../java.base/java/lang/Object.html#equals%28java.lang.Object%29)` in class `[Object](../../../java.base/java/lang/Object.html "class in java.lang")` Parameters: `obj` \- the reference object with which to compare. Returns: `true` if this object is the same as the obj argument; `false` otherwise. See Also: [Object.hashCode()](../../../java.base/java/lang/Object.html#hashCode%28%29), [HashMap](../../../java.base/java/util/HashMap.html "class in java.util") * #### 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. Overrides: `[hashCode](../../../java.base/java/lang/Object.html#hashCode%28%29)` in class `[Object](../../../java.base/java/lang/Object.html "class in java.lang")` Returns: value-based hash code for this call site descriptor. See Also: [Object.equals(java.lang.Object)](../../../java.base/java/lang/Object.html#equals%28java.lang.Object%29), [System.identityHashCode(java.lang.Object)](../../../java.base/java/lang/System.html#identityHashCode%28java.lang.Object%29) * #### toString public [String](../../../java.base/java/lang/String.html "class in java.lang") toString() Returns the string representation of this call site descriptor, of the format `name(parameterTypes)returnType@lookup`. Overrides: `[toString](../../../java.base/java/lang/Object.html#toString%28%29)` in class `[Object](../../../java.base/java/lang/Object.html "class in java.lang")` Returns: a string representation of the object.
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2025, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.