java.dyn
Class CallSite

java.lang.Object
  extended by sun.dyn.CallSiteImpl
      extended by java.dyn.CallSite

public class CallSite
extends sun.dyn.CallSiteImpl

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.

See Also:
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

CallSite

public CallSite(Object caller,
                String name,
                MethodType type)
Class is disabled.

Make a call site given the parameters from a call to the bootstrap method. The resulting call site is in an unlinked state, which means that before it is returned from a bootstrap method call it must be provided with a target method via a call to setTarget(java.dyn.MethodHandle).

Parameters:
caller - the class in which the relevant invokedynamic instruction occurs
name - the name specified by the invokedynamic instruction
type - the method handle type derived from descriptor of the invokedynamic instruction
Method Detail

initialTarget

protected MethodHandle initialTarget()
Class is disabled.

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. (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.


getTarget

public MethodHandle getTarget()
Class is disabled.

Report the current linkage state of the call site. (This is mutable.) The value may not be null after the 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.

Overrides:
getTarget in class sun.dyn.CallSiteImpl
Returns:
the current linkage state of the call site
See Also:
setTarget(java.dyn.MethodHandle)

setTarget

public void setTarget(MethodHandle target)
Class is disabled.

Link or relink the call site, by setting its target method.

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.

Overrides:
setTarget in class sun.dyn.CallSiteImpl
Parameters:
target - the new target, or null if it is to be unlinked
Throws:
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()

checkTarget

protected void checkTarget(MethodHandle target)
Class is disabled.


canSetTarget

protected boolean canSetTarget(MethodHandle target)
Class is disabled.


callerClass

public Class<?> callerClass()
Class is disabled.

Report the class containing the call site. This is an immutable property of the call site, set from the first argument to the constructor.

Returns:
class containing the call site

name

public String name()
Class is disabled.

Report the method name specified in the 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.

Returns:
method name specified by the call site

nameComponents

public Object[] nameComponents()
Class is disabled.

Report the method name specified in the 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.

Returns:
method name components specified by the call site

type

public MethodType type()
Class is disabled.

Report the resolved result and parameter types of this call site, which are derived from its bytecode-level invocation descriptor. The types are packaged into a 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.

Returns:
method type specified by the call site

toString

public String toString()
Suppressed. calls hashCode(), which may be nondeterministic

Description copied from class: Object
Returns a string representation of the object. In general, the 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())
 

Overrides:
toString in class Object
Returns:
a string representation of the object.