APIdia Launch Partner
Top Description Fields Constructors Methods
jdk.dynalink

public Class CallSiteDescriptor

extends SecureLookupSupplier
Class Inheritance
Imports
java.lang.invoke.MethodHandles, .MethodHandles.Lookup, .MethodType, java.util.Objects, java.util.function.Supplier

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 to encapsulate the MethodHandles.Lookup object. This lookup should be used to find method handles to set as targets of the call site described by this descriptor.

Since
9

Field Summary

Modifier and TypeField and Description
private final MethodType
private final Operation
Inherited from jdk.dynalink.SecureLookupSupplier:
GET_LOOKUP_PERMISSION_NAME

Constructor Summary

AccessConstructor and Description
public
CallSiteDescriptor(final MethodHandles.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.
lookup
,
final Operation
the dynamic operation at the call site.
operation
,
final 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.
methodType
)

Creates a new call site descriptor.

Method Summary

Modifier and TypeMethod and Description
private static void
alwaysAssert(final boolean cond, final Supplier<String> errorMessage)

private void
assertChangeInvariants(final CallSiteDescriptor changed, final String caller)

public final CallSiteDescriptor

Returns:

a call site descriptor with changed method type.
changeMethodType
(final MethodType
the new method type
newMethodType
)

Finds or creates a call site descriptor that only differs in its method type from this descriptor.

protected CallSiteDescriptor

Returns:

a call site descriptor with the changed method type.
changeMethodTypeInternal
(final MethodType
the new method type
newMethodType
)

Finds or creates a call site descriptor that only differs in its method type from this descriptor.

public final CallSiteDescriptor

Returns:

a call site descriptor with the changed operation.
changeOperation
(final Operation
the new operation
newOperation
)

Finds or creates a call site descriptor that only differs in its operation from this descriptor.

protected CallSiteDescriptor

Returns:

a call site descriptor with the changed operation.
changeOperationInternal
(final Operation
the new operation
newOperation
)

Finds or creates a call site descriptor that only differs in its operation from this descriptor.

public boolean
equals(final Object obj)

Overrides java.lang.Object.equals.

Returns true if this call site descriptor is equal to the passed object.

public final MethodType

Returns:

type of the method at the call site.
getMethodType
()

The type of the method at the call site.

public final Operation

Returns:

the operation at the call site.
getOperation
()

Returns the operation at the call site.

public int

Returns:

value-based hash code for this call site descriptor.
hashCode
()

Overrides java.lang.Object.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.

private static int

Returns:

a hash code for the object..
lookupHashCode
(final MethodHandles.Lookup
the lookup object.
lookup
)

Returns a value-based hash code for the passed lookup object.

private static boolean

Returns:

true if the two lookups are equal, false otherwise.
lookupsEqual
(final MethodHandles.Lookup
first lookup
l1
,
final MethodHandles.Lookup
second lookup
l2
)

Compares two lookup objects for value-based equality.

public String
toString()

Overrides java.lang.Object.toString.

Returns the string representation of this call site descriptor, of the format name(parameterTypes)returnType@lookup.

Inherited from jdk.dynalink.SecureLookupSupplier:
getLookupgetLookupPrivileged

Field Detail

methodTypeback to summary
private final MethodType methodType
operationback to summary
private final Operation operation

Constructor Detail

CallSiteDescriptorback to summary
public CallSiteDescriptor(final MethodHandles.Lookup lookup, final Operation operation, final MethodType methodType)

Creates a new call site descriptor.

Parameters
lookup:MethodHandles.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:Operation

the dynamic operation at the call site.

methodType: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.

Method Detail

alwaysAssertback to summary
private static void alwaysAssert(final boolean cond, final Supplier<String> errorMessage)
assertChangeInvariantsback to summary
private void assertChangeInvariants(final CallSiteDescriptor changed, final String caller)
changeMethodTypeback to summary
public final CallSiteDescriptor changeMethodType(final MethodType newMethodType)

Finds or creates a call site descriptor that only differs in its method type from this descriptor. Invokes changeMethodTypeInternal(MethodType).

Parameters
newMethodType:MethodType

the new method type

Returns:CallSiteDescriptor

a call site descriptor with changed method type.

Exceptions
NullPointerException:
if newMethodType is null.
changeMethodTypeInternalback to summary
protected CallSiteDescriptor changeMethodTypeInternal(final MethodType 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).

Parameters
newMethodType:MethodType

the new method type

Returns:CallSiteDescriptor

a call site descriptor with the changed method type.

changeOperationback to summary
public final CallSiteDescriptor changeOperation(final Operation newOperation)

Finds or creates a call site descriptor that only differs in its operation from this descriptor. Invokes changeOperationInternal(Operation).

Parameters
newOperation:Operation

the new operation

Returns:CallSiteDescriptor

a call site descriptor with the changed operation.

Exceptions
NullPointerException:
if newOperation is null.
changeOperationInternalback to summary
protected CallSiteDescriptor changeOperationInternal(final Operation 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).

Parameters
newOperation:Operation

the new operation

Returns:CallSiteDescriptor

a call site descriptor with the changed operation.

equalsback to summary
public boolean equals(final Object obj)

Overrides java.lang.Object.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 same java.lang.invoke.MethodHandles.Lookup#lookupClass() and java.lang.invoke.MethodHandles.Lookup#lookupModes().

Annotations
@Override
getMethodTypeback to summary
public final MethodType getMethodType()

The type of the method at the call site.

Returns:MethodType

type of the method at the call site.

getOperationback to summary
public final Operation getOperation()

Returns the operation at the call site.

Returns:Operation

the operation at the call site.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.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.

Returns:int

value-based hash code for this call site descriptor.

Annotations
@Override
lookupHashCodeback to summary
private static int lookupHashCode(final MethodHandles.Lookup lookup)

Returns a value-based hash code for the passed lookup object. It is based on the lookup object's java.lang.invoke.MethodHandles.Lookup#lookupClass() and java.lang.invoke.MethodHandles.Lookup#lookupModes() values.

Parameters
lookup:MethodHandles.Lookup

the lookup object.

Returns:int

a hash code for the object..

lookupsEqualback to summary
private static boolean lookupsEqual(final MethodHandles.Lookup l1, final MethodHandles.Lookup l2)

Compares two lookup objects for value-based equality. They are considered equal if they have the same java.lang.invoke.MethodHandles.Lookup#lookupClass() and java.lang.invoke.MethodHandles.Lookup#lookupModes().

Parameters
l1:MethodHandles.Lookup

first lookup

l2:MethodHandles.Lookup

second lookup

Returns:boolean

true if the two lookups are equal, false otherwise.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns the string representation of this call site descriptor, of the format name(parameterTypes)returnType@lookup.

Annotations
@Override