Home » openjdk-7 » java.lang.invoke » [javadoc | source]
public class: ConstantCallSite [javadoc | source]
A {@code ConstantCallSite} is a CallSite whose target is permanent, and can never be changed. An {@code invokedynamic} instruction linked to a {@code ConstantCallSite} is permanently bound to the call site's target.
Fields inherited from java.lang.invoke.CallSite:
 public ConstantCallSite(MethodHandle target) 
    Creates a call site with a permanent target.
    target - the target to be permanently associated with this call site
    NullPointerException - if the proposed target is null
 protected ConstantCallSite(MethodType targetType,
    MethodHandle createTargetHook) throws Throwable 
    Creates a call site with a permanent target, possibly bound to the call site itself.

    During construction of the call site, the {@code createTargetHook} is invoked to produce the actual target, as if by a call of the form {@code (MethodHandle) createTargetHook.invoke(this)}.

    Note that user code cannot perform such an action directly in a subclass constructor, since the target must be fixed before the {@code ConstantCallSite} constructor returns.

    The hook is said to bind the call site to a target method handle, and a typical action would be {@code someTarget.bindTo(this)}. However, the hook is free to take any action whatever, including ignoring the call site and returning a constant target.

    The result returned by the hook must be a method handle of exactly the same type as the call site.

    While the hook is being called, the new {@code ConstantCallSite} object is in a partially constructed state. In this state, a call to {@code getTarget}, or any other attempt to use the target, will result in an {@code IllegalStateException}. It is legal at all times to obtain the call site's type using the {@code type} method.

    targetType - the type of the method handle to be permanently associated with this call site
    createTargetHook - a method handle to invoke (on the call site) to produce the call site's target
    WrongMethodTypeException - if the hook cannot be invoked on the required arguments, or if the target returned by the hook is not of the given {@code targetType}
    NullPointerException - if the hook returns a null value
    ClassCastException - if the hook returns something other than a {@code MethodHandle}
    Throwable - anything else thrown by the the hook function
Method from java.lang.invoke.ConstantCallSite Summary:
dynamicInvoker,   getTarget,   setTarget
Methods from java.lang.invoke.CallSite:
checkTargetChange,   dynamicInvoker,   getTarget,   getTargetVolatile,   initializeFromJVM,   makeDynamicInvoker,   makeSite,   setTarget,   setTargetNormal,   setTargetVolatile,   type,   uninitializedCallSite
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.lang.invoke.ConstantCallSite Detail:
 public final MethodHandle dynamicInvoker() 
    Returns this call site's permanent target. Since that target will never change, this is a correct implementation of CallSite.dynamicInvoker .
 public final MethodHandle getTarget() 
    Returns the target method of the call site, which behaves like a {@code final} field of the {@code ConstantCallSite}. That is, the the target is always the original value passed to the constructor call which created this instance.
 public final  void setTarget(MethodHandle ignore)