java.dyn
Class InvokeDynamic

java.lang.Object
  extended by java.dyn.InvokeDynamic

public final class InvokeDynamic
extends Object

Disabled: no SafeJ information.

Syntactic marker to request javac to emit an invokedynamic instruction. An invokedynamic instruction is a 5-byte bytecoded instruction which begins with an opcode byte of value 186 (0xBA), and is followed by a two-byte index of a NameAndType constant pool entry, then by two zero bytes. The constant pool reference gives the method name and argument and return types of the call site; there is no other information provided at the call site.

The invokedynamic instruction is incomplete without a target method. The target method is a property of the reified call site object (of type CallSite) which is in a one-to-one association with each corresponding invokedynamic instruction. The call site object is initially produced by a bootstrap method associated with the call site, via the various overloadings of Linkage.registerBootstrapMethod(java.lang.Class, java.dyn.MethodHandle).

The type InvokeDynamic has no particular meaning as a class or interface supertype, or an object type; it can never be instantiated. Logically, it denotes a source of all dynamically typed methods. It may be viewed as a pure syntactic marker (an importable one) of static calls.

Here are some examples of usage:

 Object x; String s; int i;
 x = InvokeDynamic.greet("world"); // greet(Ljava/lang/String;)Ljava/lang/Object;
 s = InvokeDynamic.<String>hail(x); // hail(Ljava/lang/Object;)Ljava/lang/String;
 InvokeDynamic.<void>cogito(); // cogito()V
 i = InvokeDynamic.<int>#"op:+"(2, 3); // "op:+"(II)I
 
Each of the above calls generates a single invokedynamic instruction with the name-and-type descriptors indicated in the comments. The argument types are taken directly from the actual arguments, while the return type is taken from the type parameter. (This type parameter may be a primtive, and it defaults to Object.) The final example uses a special syntax for uttering non-Java names. Any name legal to the JVM may be given between the double quotes. None of these calls is complete without a bootstrap method, which must be registered by the static initializer of the enclosing class.


Method Summary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait