Freigeben über


CallSite Class

Definition

A CallSite is a holder for a variable MethodHandle, which is called its target.

[Android.Runtime.Register("java/lang/invoke/CallSite", ApiSince=26, DoNotGenerateAcw=true)]
public abstract class CallSite : Java.Lang.Object
[<Android.Runtime.Register("java/lang/invoke/CallSite", ApiSince=26, DoNotGenerateAcw=true)>]
type CallSite = class
    inherit Object
Inheritance
CallSite
Derived
Attributes

Remarks

A CallSite is a holder for a variable MethodHandle, which is called its target. An invokedynamic instruction linked to a CallSite delegates all calls to the site's current target. A CallSite may be associated with several invokedynamic instructions, or it may be "free floating", associated with none. In any case, it may be invoked through an associated method handle called its #dynamicInvoker dynamic invoker.

CallSite is an abstract class which does not allow direct subclassing by users. It has three immediate, concrete subclasses that may be either instantiated or subclassed. <ul> <li>If a mutable target is not required, an invokedynamic instruction may be permanently bound by means of a ConstantCallSite constant call site. <li>If a mutable target is required which has volatile variable semantics, because updates to the target must be immediately and reliably witnessed by other threads, a VolatileCallSite volatile call site may be used. <li>Otherwise, if a mutable target is required, a MutableCallSite mutable call site may be used. </ul>

A non-constant call site may be <em>relinked</em> by changing its target. The new target must have the same MethodHandle#type() type as the previous target. Thus, though a call site can be relinked to a series of successive targets, it cannot change its type.

Here is a sample use of call sites and bootstrap methods which links every dynamic call site to print its arguments: <blockquote>

{@code
            static void test() throws Throwable {
                // THE FOLLOWING LINE IS PSEUDOCODE FOR A JVM INSTRUCTION
                InvokeDynamic[#bootstrapDynamic].baz("baz arg", 2, 3.14);
            }
            private static void printArgs(Object... args) {
              System.out.println(java.util.Arrays.deepToString(args));
            }
            private static final MethodHandle printArgs;
            static {
              MethodHandles.Lookup lookup = MethodHandles.lookup();
              Class thisClass = lookup.lookupClass();  // (who am I?)
              printArgs = lookup.findStatic(thisClass,
                  "printArgs", MethodType.methodType(void.class, Object[].class));
            }
            private static CallSite bootstrapDynamic(MethodHandles.Lookup caller, String name, MethodType type) {
              // ignore caller and name, but match the type:
              return new ConstantCallSite(printArgs.asType(type));
            }
            }

</blockquote>

Java documentation for java.lang.invoke.CallSite.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

CallSite(IntPtr, JniHandleOwnership)

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
Target
ThresholdClass
ThresholdType

Methods

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
DynamicInvoker()

Produces a method handle equivalent to an invokedynamic instruction which has been linked to this call site.

Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
Type()

Returns the type of this call site's target.

UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to