Spec-Zone .ru
спецификации, руководства, описания, API
|
|
Java™ Platform Standard Ed. 7 DRAFT ea-b118 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.dyn.InvokeDynamic
public final class InvokeDynamic extends Object
InvokeDynamic
is a class with neither methods nor instances,
which serves only as a syntactic marker in Java source code for
an invokedynamic
instruction.
(See the package information for specifics on this instruction.)
The invokedynamic
instruction is incomplete without a target method.
The target method is a property of the reified call site object
which is linked to each active invokedynamic
instruction.
The call site object is initially produced by a
bootstrap method
associated with the class whose bytecodes include the dynamic call site.
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 of static calls.
It may be imported for ease of use.
Here are some examples:
Each of the above calls generates a single invokedynamic instruction with the name-and-type descriptors indicated in the comments.@BootstrapMethod(value=Here.class, name="bootstrapDynamic") static void example() throws Throwable { Object x; String s; int i; x = InvokeDynamic.greet("world"); // greet(Ljava/lang/String;)Ljava/lang/Object; s = (String) InvokeDynamic.hail(x); // hail(Ljava/lang/Object;)Ljava/lang/String; InvokeDynamic.cogito(); // cogito()V i = (int) InvokeDynamic.#"op:+"(2, 3); // "op:+"(II)I } static MethodHandle bootstrapDynamic(Class caller, String name, MethodType type) { ... }
The argument types are taken directly from the actual arguments, while the return type corresponds to the target of the assignment. (Currently, the return type must be given as a false type parameter. This type parameter is an irregular use of the generic type syntax, and is likely to change in favor of a convention based on target typing.)
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 declared for the enclosing class or method.
Modifier and Type | Method and Description |
---|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
|
Java™ Platform Standard Ed. 7 DRAFT ea-b118 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1993, 2010, Oracle Corporation. All rights reserved.