Spec-Zone .ru
спецификации, руководства, описания, API
Please note that the specifications and other information contained herein are not final and are subject to change. The information is being made available to you solely for purpose of evaluation.

Java™ Platform
Standard Ed. 7

DRAFT ea-b118

java.dyn
Annotation Type BootstrapMethod


@Target(value={TYPE_USE,TYPE,METHOD,CONSTRUCTOR})
@Retention(value=SOURCE)
public @interface BootstrapMethod

Annotation on InvokeDynamic method calls which requests the JVM to use a specific bootstrap method to link the call. This annotation is not retained as such in the class file, but is transformed into a constant-pool entry for the invokedynamic instruction which specifies the desired bootstrap method.

If only the value is given, it must name a subclass of CallSite with a constructor which accepts a class, string, and method type. If the value and name are both given, there must be a static method in the given class of the given name which accepts a class, string, and method type, and returns a reference coercible to CallSite.

This annotation can be placed either on the return type of a single InvokeDynamic call (see examples) or else it can be placed on an enclosing class or method, where it determines a default bootstrap method for any InvokeDynamic calls which are not specifically annotated with a bootstrap method. Every InvokeDynamic call must be given a bootstrap method.

Examples:

@BootstrapMethod(value=MyLanguageRuntime.class, name="bootstrapDynamic")
String x = (String) InvokeDynamic.greet();
//BSM => MyLanguageRuntime.bootstrapDynamic(Here.class, "greet", methodType(String.class))
@BootstrapMethod(MyCallSite.class)
void example() throws Throwable {
    InvokeDynamic.greet();
    //BSM => new MyCallSite(Here.class, "greet", methodType(void.class))
}


Required Element Summary
Modifier and Type Required Element and Description
 Class<?> value
          The class containing the bootstrap method.
 
Optional Element Summary
Modifier and Type Optional Element and Description
 Class<?>[] arguments
          The argument types of the bootstrap method, as passed out by the JVM.
 String name
          The name of the bootstrap method.
 

Element Detail

value

public abstract Class<?> value
The class containing the bootstrap method.

name

public abstract String name
The name of the bootstrap method. If this is the empty string, an instance of the bootstrap class is created, and a constructor is invoked. Otherwise, there must be a static method of the required name.

Default:
""

arguments

public abstract Class<?>[] arguments
The argument types of the bootstrap method, as passed out by the JVM. There is usually no reason to override the default.

Default:
{java.lang.Class.class, java.lang.String.class, java.dyn.MethodType.class}

Java™ Platform
Standard Ed. 7

DRAFT ea-b118

Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright © 1993, 2010, Oracle Corporation. All rights reserved.
DRAFT ea-b118

Scripting on this page tracks web page traffic, but does not change the content in any way.