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(MethodHandles.Lookup lookup,
Operation operation,
MethodType methodType) |
Creates a new call site descriptor.
|
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 . |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
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()
.equals
in class Object
obj
- the reference object with which to compare.true
if this object is the same as the obj
argument; false
otherwise.Object.hashCode()
,
HashMap
public int hashCode()
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
Submit a bug or feature
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 2015, 2017, Oracle and/or its affiliates. 500 Oracle Parkway
Redwood Shores, CA 94065 USA. All rights reserved.
DRAFT 9-Ubuntu+0-9b153-2