|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsun.dyn.CallSiteImpl
java.dyn.CallSite
public class CallSite
Disabled: no SafeJ information.
An invokedynamic
call site, as reified by the
containing class's bootstrap method.
Every call site object corresponds to a distinct instance
of the invokedynamic
instruction, and vice versa.
Every call site has one state variable, called the target
.
It is typed as a MethodHandle
. This state is never null, and
it is the responsibility of the bootstrap method to produce call sites
which have been pre-linked to an initial target method.
(Note: The bootstrap method may elect to produce call sites of a
language-specific subclass of CallSite
. In such a case,
the subclass may claim responsibility for initializing its target to
a non-null value, by overriding initialTarget()
.)
An invokedynamic
instruction which has not yet been executed
is said to be unlinked. When an unlinked call site is executed,
the containing class's bootstrap method is called to manufacture a call site,
for the instruction. If the bootstrap method does not assign a non-null
value to the new call site's target variable, the method initialTarget()
is called to produce the new call site's first target method.
Linkage.registerBootstrapMethod(java.lang.Class, java.dyn.MethodHandle)
Field Summary |
---|
Fields inherited from class sun.dyn.CallSiteImpl |
---|
caller, callerBCI, callerMID, name, type |
Constructor Summary | |
---|---|
CallSite(Object caller,
String name,
MethodType type)
Make a call site given the parameters from a call to the bootstrap method. |
Method Summary | |
---|---|
Class<?> |
callerClass()
Report the class containing the call site. |
protected boolean |
canSetTarget(MethodHandle target)
|
protected void |
checkTarget(MethodHandle target)
|
MethodHandle |
getTarget()
Report the current linkage state of the call site. |
protected MethodHandle |
initialTarget()
Just after a call site is created by a bootstrap method handle, if the target has not been initialized by the factory method itself, the method initialTarget is called to produce an initial
non-null target. |
String |
name()
Report the method name specified in the invokedynamic instruction. |
Object[] |
nameComponents()
Report the method name specified in the invokedynamic instruction,
as a series of components, individually demangled according to
the standard convention
specified here. |
void |
setTarget(MethodHandle target)
Link or relink the call site, by setting its target method. |
String |
toString()
Returns a string representation of the object. |
MethodType |
type()
Report the resolved result and parameter types of this call site, which are derived from its bytecode-level invocation descriptor. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CallSite(Object caller, String name, MethodType type)
setTarget(java.dyn.MethodHandle)
.
caller
- the class in which the relevant invokedynamic
instruction occursname
- the name specified by the invokedynamic
instructiontype
- the method handle type derived from descriptor of the invokedynamic
instructionMethod Detail |
---|
protected MethodHandle initialTarget()
initialTarget
is called to produce an initial
non-null target. (Live call sites must never have null targets.)
If the bootstrap method itself does not initialize the call site,
this method must be overridden, because it just raises an
InvokeDynamicBootstrapError
, which in turn causes the
linkage of the invokedynamic
instruction to terminate
abnormally.
public MethodHandle getTarget()
CallSite
object is returned
from the bootstrap method of the invokedynamic
instruction.
When an invokedynamic
instruction is executed, the target method
of its associated call site
object is invoked directly,
as if via MethodHandle
.invoke
.
The interactions of getTarget
with memory are the same
as of a read from an ordinary variable, such as an array element or a
non-volatile, non-final field.
In particular, the current thread may choose to reuse the result of a previous read of the target from memory, and may fail to see a recent update to the target by another thread.
getTarget
in class sun.dyn.CallSiteImpl
setTarget(java.dyn.MethodHandle)
public void setTarget(MethodHandle target)
The interactions of setTarget
with memory are the same
as of a write to an ordinary variable, such as an array element or a
non-volatile, non-final field.
In particular, unrelated threads may fail to see the updated target until they perform a read from memory. Stronger guarantees can be created by putting appropriate operations into the bootstrap method and/or the target methods used at any given call site.
setTarget
in class sun.dyn.CallSiteImpl
target
- the new target, or null if it is to be unlinked
NullPointerException
- if the proposed new target is null
WrongMethodTypeException
- if the proposed new target
has a method type that differs from the call site's type()
protected void checkTarget(MethodHandle target)
protected boolean canSetTarget(MethodHandle target)
public Class<?> callerClass()
public String name()
invokedynamic
instruction.
This is an immutable property of the call site, set from the second argument to the constructor.
Note that the name is a JVM bytecode name, and as such can be any
non-empty string, as long as it does not contain certain "dangerous"
characters such as slash '/'
and dot '.'
.
See the Java Virtual Machine specification for more details.
Application such as a language runtimes may need to encode arbitrary program element names and other configuration information into the name. A standard convention for doing this is specified here.
public Object[] nameComponents()
invokedynamic
instruction,
as a series of components, individually demangled according to
the standard convention
specified here.
Non-empty runs of characters between dangerous characters are demangled. Each component is either a completely arbitrary demangled string, or else a character constant for a punctuation character, typically ':'. (In principle, the character can be any dangerous character that the JVM lets through in a method name, such as '$' or ']'. Runtime implementors are encouraged to use colon ':' for building structured names.)
In the common case where the name contains no dangerous characters, the result is an array whose only element array is the demangled name at the call site. Such a demangled name can be any sequence of any number of any unicode characters.
public MethodType type()
MethodType
.
Any linked target of this call site must be exactly this method type.
This is an immutable property of the call site, set from the third argument to the constructor.
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |