public class CallSiteDescriptor extends Object
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.
Modifier and Type | Field and Description |
---|---|
static String |
GET_LOOKUP_PERMISSION_NAME
The name of a runtime permission to invoke the
getLookup()
method. |
Constructor and Description |
---|
CallSiteDescriptor(MethodHandles.Lookup lookup,
Operation operation,
MethodType methodType)
Creates a new call site descriptor.
|
Modifier and Type | Method and Description |
---|---|
CallSiteDescriptor |
changeMethodType(MethodType newMethodType)
Creates a new call site descriptor from this descriptor, which is
identical to this, except it changes the method type.
|
protected CallSiteDescriptor |
changeMethodTypeInternal(MethodType newMethodType)
Creates a new call site descriptor from this descriptor, which is
identical to this, except it changes the method type.
|
boolean |
equals(Object obj)
Returns true if this call site descriptor is equal to the passed object.
|
MethodHandles.Lookup |
getLookup()
Returns the lookup that should be used to find method handles to set as
targets of the call site described by this descriptor.
|
protected MethodHandles.Lookup |
getLookupPrivileged()
Returns the value of
getLookup() without a security check. |
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 . |
public static final String GET_LOOKUP_PERMISSION_NAME
getLookup()
method.public CallSiteDescriptor(MethodHandles.Lookup lookup, Operation operation, MethodType methodType)
lookup
- the lookup object describing the class the call site belongs to.operation
- the dynamic operation at the call site.methodType
- the method type of the call site.public final Operation getOperation()
public final MethodType getMethodType()
public final MethodHandles.Lookup getLookup()
java.lang.invoke
bootstrap method, it should
be the lookup passed to the bootstrap.SecurityException
- if the lookup isn't the
MethodHandles.publicLookup()
and a security manager is present,
and a check for RuntimePermission("dynalink.getLookup")
fails.protected final MethodHandles.Lookup getLookupPrivileged()
getLookup()
without a security check. Can
be used by subclasses to access the lookup quickly.getLookup()
.public final CallSiteDescriptor changeMethodType(MethodType newMethodType)
changeMethodTypeInternal(MethodType)
and checks that it returns
a descriptor of the same class as this descriptor.newMethodType
- the new method typeRuntimeException
- if changeMethodTypeInternal(MethodType)
returned a descriptor of different class than this object.NullPointerException
- if changeMethodTypeInternal(MethodType)
returned null.protected CallSiteDescriptor changeMethodTypeInternal(MethodType newMethodType)
newMethodType
- the new method typepublic 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)
Copyright © 2015, 2016, Oracle and/or its affiliates. All rights reserved.
DRAFT 9-internal+0-2016-02-27-130607.doko.src