author | psandoz |
Fri, 08 Sep 2017 10:46:46 -0700 | |
changeset 48826 | c4d9d1b08e2e |
parent 47250 | a0f26f0da4f1 |
child 49576 | 535498e7602f |
permissions | -rw-r--r-- |
2707
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
1 |
/* |
45433 | 2 |
* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. |
2707
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
4 |
* |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2707
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2707
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
10 |
* |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
15 |
* accompanied this code). |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
16 |
* |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
20 |
* |
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2707
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
24 |
*/ |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
25 |
|
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
26 |
/** |
48826 | 27 |
* The {@code java.lang.invoke} package provides low-level primitives for interacting |
28 |
* with the Java Virtual Machine. |
|
8346
3b891698c4ec
7012650: implement JSR 292 EG adjustments through January 2010
jrose
parents:
8345
diff
changeset
|
29 |
* |
5722
4ada807383c8
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4537
diff
changeset
|
30 |
* <p> |
48826 | 31 |
* As described in the Java Virtual Machine Specification, certain types in this package |
32 |
* are given special treatment by the virtual machine: |
|
5722
4ada807383c8
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4537
diff
changeset
|
33 |
* <ul> |
36934 | 34 |
* <li>The classes {@link java.lang.invoke.MethodHandle MethodHandle} |
35 |
* {@link java.lang.invoke.VarHandle VarHandle} contain |
|
8346
3b891698c4ec
7012650: implement JSR 292 EG adjustments through January 2010
jrose
parents:
8345
diff
changeset
|
36 |
* <a href="MethodHandle.html#sigpoly">signature polymorphic methods</a> |
3b891698c4ec
7012650: implement JSR 292 EG adjustments through January 2010
jrose
parents:
8345
diff
changeset
|
37 |
* which can be linked regardless of their type descriptor. |
3b891698c4ec
7012650: implement JSR 292 EG adjustments through January 2010
jrose
parents:
8345
diff
changeset
|
38 |
* Normally, method linkage requires exact matching of type descriptors. |
7051
1c545d70a157
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5725
diff
changeset
|
39 |
* </li> |
5722
4ada807383c8
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4537
diff
changeset
|
40 |
* |
4ada807383c8
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4537
diff
changeset
|
41 |
* <li>The JVM bytecode format supports immediate constants of |
48826 | 42 |
* the classes {@link java.lang.invoke.MethodHandle MethodHandle} and |
43 |
* {@link java.lang.invoke.MethodType MethodType}. |
|
44 |
* </li> |
|
45 |
* |
|
46 |
* <li>The {@code invokedynamic} instruction makes use of bootstrap {@code MethodHandle} |
|
47 |
* constants to dynamically resolve {@code CallSite} objects for custom method invocation |
|
48 |
* behavior. |
|
49 |
* </li> |
|
50 |
* |
|
51 |
* <li>The {@code ldc} instruction makes use of bootstrap {@code MethodHandle} constants |
|
52 |
* to dynamically resolve custom constant values. |
|
7051
1c545d70a157
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5725
diff
changeset
|
53 |
* </li> |
5722
4ada807383c8
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4537
diff
changeset
|
54 |
* </ul> |
4ada807383c8
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4537
diff
changeset
|
55 |
* |
48826 | 56 |
* <h1><a id="jvm_mods"></a>Dynamic resolution of call sites and constants</h1> |
9752
88ab34b6da6d
7032323: code changes for JSR 292 EG adjustments to API, through Public Review
jrose
parents:
9645
diff
changeset
|
57 |
* The following low-level information summarizes relevant parts of the |
88ab34b6da6d
7032323: code changes for JSR 292 EG adjustments to API, through Public Review
jrose
parents:
9645
diff
changeset
|
58 |
* Java Virtual Machine specification. For full details, please see the |
88ab34b6da6d
7032323: code changes for JSR 292 EG adjustments to API, through Public Review
jrose
parents:
9645
diff
changeset
|
59 |
* current version of that specification. |
5722
4ada807383c8
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4537
diff
changeset
|
60 |
* |
48826 | 61 |
* <h2><a id="indyinsn"></a>Dynamically-computed call sites</h2> |
62 |
* An {@code invokedynamic} instruction is originally in an unlinked state. |
|
63 |
* In this state, there is no target method for the instruction to invoke. |
|
7555
a279ebc3b25c
6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents:
7051
diff
changeset
|
64 |
* <p> |
48826 | 65 |
* Before the JVM can execute an {@code invokedynamic} instruction, |
66 |
* the instruction must first be <em>linked</em>. |
|
7051
1c545d70a157
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5725
diff
changeset
|
67 |
* Linking is accomplished by calling a <em>bootstrap method</em> |
48826 | 68 |
* which is given the static information content of the call, |
69 |
* and which must produce a {@link java.lang.invoke.CallSite} |
|
70 |
* that gives the behavior of the invocation. |
|
7051
1c545d70a157
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5725
diff
changeset
|
71 |
* <p> |
1c545d70a157
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5725
diff
changeset
|
72 |
* Each {@code invokedynamic} instruction statically specifies its own |
1c545d70a157
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5725
diff
changeset
|
73 |
* bootstrap method as a constant pool reference. |
48826 | 74 |
* The constant pool reference also specifies the invocation's name and method type descriptor, |
75 |
* just like {@code invokestatic} and the other invoke instructions. |
|
76 |
* |
|
77 |
* <h2><a id="condycon"></a>Dynamically-computed constants</h2> |
|
78 |
* The constant pool may contain constants tagged {@code CONSTANT_Dynamic}, |
|
79 |
* equipped with bootstrap methods which perform their resolution. |
|
80 |
* Such a <em>dynamic constant</em> is originally in an unresolved state. |
|
81 |
* Before the JVM can use a dynamically-computed constant, it must first be <em>resolved</em>. |
|
82 |
* Dynamically-computed constant resolution is accomplished by calling a <em>bootstrap method</em> |
|
83 |
* which is given the static information content of the constant, |
|
84 |
* and which must produce a value of the constant's statically declared type. |
|
7051
1c545d70a157
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5725
diff
changeset
|
85 |
* <p> |
48826 | 86 |
* Each dynamically-computed constant statically specifies its own |
87 |
* bootstrap method as a constant pool reference. |
|
88 |
* The constant pool reference also specifies the constant's name and field type descriptor, |
|
89 |
* just like {@code getstatic} and the other field reference instructions. |
|
90 |
* (Roughly speaking, a dynamically-computed constant is to a dynamically-computed call site |
|
91 |
* as a {@code CONSTANT_Fieldref} is to a {@code CONSTANT_Methodref}.) |
|
92 |
* |
|
93 |
* <h2><a id="bsm"></a>Execution of bootstrap methods</h2> |
|
94 |
* Resolving a dynamically-computed call site or constant |
|
95 |
* starts with resolving constants from the constant pool for the |
|
96 |
* following items: |
|
7051
1c545d70a157
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5725
diff
changeset
|
97 |
* <ul> |
48826 | 98 |
* <li>the bootstrap method, a {@code CONSTANT_MethodHandle}</li> |
99 |
* <li>the {@code Class} or {@code MethodType} derived from |
|
100 |
* type component of the {@code CONSTANT_NameAndType} descriptor</li> |
|
101 |
* <li>static arguments, if any (note that static arguments can themselves be |
|
102 |
* dynamically-computed constants)</li> |
|
7051
1c545d70a157
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5725
diff
changeset
|
103 |
* </ul> |
47250
a0f26f0da4f1
8185993: MethodHandle.invokeWithArguments jumbo-arity
jrose
parents:
47216
diff
changeset
|
104 |
* <p> |
48826 | 105 |
* The bootstrap method is then invoked, as if by |
106 |
* {@link java.lang.invoke.MethodHandle#invoke MethodHandle.invoke}, |
|
107 |
* with the following arguments: |
|
108 |
* <ul> |
|
109 |
* <li>a {@code MethodHandles.Lookup}, which is a lookup object on the <em>caller class</em> |
|
110 |
* in which dynamically-computed constant or call site occurs</li> |
|
111 |
* <li>a {@code String}, the name mentioned in the {@code CONSTANT_NameAndType}</li> |
|
112 |
* <li>a {@code MethodType} or {@code Class}, the resolved type descriptor of the {@code CONSTANT_NameAndType}</li> |
|
113 |
* <li>a {@code Class}, the resolved type descriptor of the constant, if it is a dynamic constant </li> |
|
114 |
* <li>the additional resolved static arguments, if any</li> |
|
115 |
* </ul> |
|
47250
a0f26f0da4f1
8185993: MethodHandle.invokeWithArguments jumbo-arity
jrose
parents:
47216
diff
changeset
|
116 |
* <p> |
48826 | 117 |
* For a dynamically-computed call site, the returned result must be a non-null reference to a |
47250
a0f26f0da4f1
8185993: MethodHandle.invokeWithArguments jumbo-arity
jrose
parents:
47216
diff
changeset
|
118 |
* {@link java.lang.invoke.CallSite CallSite}. |
7555
a279ebc3b25c
6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents:
7051
diff
changeset
|
119 |
* The type of the call site's target must be exactly equal to the type |
48826 | 120 |
* derived from the invocation's type descriptor and passed to |
121 |
* the bootstrap method. If these conditions are not met, a {@code BootstrapMethodError} is thrown. |
|
122 |
* On success the call site then becomes permanently linked to the {@code invokedynamic} |
|
123 |
* instruction. |
|
7555
a279ebc3b25c
6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents:
7051
diff
changeset
|
124 |
* <p> |
48826 | 125 |
* For a dynamically-computed constant, the result of the bootstrap method is cached |
126 |
* as the resolved constant value. |
|
127 |
* <p> |
|
128 |
* If an exception, {@code E} say, occurs during execution of the bootstrap method, then |
|
129 |
* resolution fails and terminates abnormally. {@code E} is rethrown if the type of |
|
42103
8e1fe4345fd7
8166974: invokedynamic implementation should not wrap Errors
psandoz
parents:
36934
diff
changeset
|
130 |
* {@code E} is {@code Error} or a subclass, otherwise a |
8e1fe4345fd7
8166974: invokedynamic implementation should not wrap Errors
psandoz
parents:
36934
diff
changeset
|
131 |
* {@code BootstrapMethodError} that wraps {@code E} is thrown. |
48826 | 132 |
* If this happens, the same error will be thrown for all |
133 |
* subsequent attempts to execute the {@code invokedynamic} instruction or load the |
|
134 |
* dynamically-computed constant. |
|
135 |
* |
|
136 |
* <h2>Timing of resolution</h2> |
|
137 |
* An {@code invokedynamic} instruction is linked just before its first execution. |
|
138 |
* A dynamically-computed constant is resolved just before the first time it is used |
|
139 |
* (by pushing it on the stack or linking it as a bootstrap method parameter). |
|
7051
1c545d70a157
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5725
diff
changeset
|
140 |
* The bootstrap method call implementing the linkage occurs within |
48826 | 141 |
* a thread that is attempting a first execution or first use. |
7051
1c545d70a157
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5725
diff
changeset
|
142 |
* <p> |
7555
a279ebc3b25c
6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents:
7051
diff
changeset
|
143 |
* If there are several such threads, the bootstrap method may be |
a279ebc3b25c
6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents:
7051
diff
changeset
|
144 |
* invoked in several threads concurrently. |
a279ebc3b25c
6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents:
7051
diff
changeset
|
145 |
* Therefore, bootstrap methods which access global application |
a279ebc3b25c
6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents:
7051
diff
changeset
|
146 |
* data must take the usual precautions against race conditions. |
a279ebc3b25c
6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents:
7051
diff
changeset
|
147 |
* In any case, every {@code invokedynamic} instruction is either |
a279ebc3b25c
6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents:
7051
diff
changeset
|
148 |
* unlinked or linked to a unique {@code CallSite} object. |
7051
1c545d70a157
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5725
diff
changeset
|
149 |
* <p> |
48826 | 150 |
* In an application which requires {@code invokedynamic} instructions with individually |
7051
1c545d70a157
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5725
diff
changeset
|
151 |
* mutable behaviors, their bootstrap methods should produce distinct |
8822
8145ab9f5f86
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
8349
diff
changeset
|
152 |
* {@link java.lang.invoke.CallSite CallSite} objects, one for each linkage request. |
7555
a279ebc3b25c
6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents:
7051
diff
changeset
|
153 |
* Alternatively, an application can link a single {@code CallSite} object |
a279ebc3b25c
6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents:
7051
diff
changeset
|
154 |
* to several {@code invokedynamic} instructions, in which case |
a279ebc3b25c
6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents:
7051
diff
changeset
|
155 |
* a change to the target method will become visible at each of |
a279ebc3b25c
6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents:
7051
diff
changeset
|
156 |
* the instructions. |
7051
1c545d70a157
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5725
diff
changeset
|
157 |
* <p> |
48826 | 158 |
* If several threads simultaneously execute a bootstrap method for a single dynamically-computed |
159 |
* call site or constant, the JVM must choose one bootstrap method result and install it visibly to |
|
7051
1c545d70a157
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5725
diff
changeset
|
160 |
* all threads. Any other bootstrap method calls are allowed to complete, but their |
48826 | 161 |
* results are ignored. |
9752
88ab34b6da6d
7032323: code changes for JSR 292 EG adjustments to API, through Public Review
jrose
parents:
9645
diff
changeset
|
162 |
|
7557
06bbd3ae0835
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7555
diff
changeset
|
163 |
* <p style="font-size:smaller;"> |
8822
8145ab9f5f86
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
8349
diff
changeset
|
164 |
* <em>Discussion:</em> |
48826 | 165 |
* These rules do not enable the JVM to share call sites, |
7555
a279ebc3b25c
6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents:
7051
diff
changeset
|
166 |
* or to issue “causeless” bootstrap method calls. |
48826 | 167 |
* Every {@code invokedynamic} instruction transitions at most once from unlinked to linked, |
8346
3b891698c4ec
7012650: implement JSR 292 EG adjustments through January 2010
jrose
parents:
8345
diff
changeset
|
168 |
* just before its first invocation. |
8822
8145ab9f5f86
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
8349
diff
changeset
|
169 |
* There is no way to undo the effect of a completed bootstrap method call. |
7557
06bbd3ae0835
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7555
diff
changeset
|
170 |
* |
48826 | 171 |
* <h2>Types of bootstrap methods</h2> |
172 |
* For a dynamically-computed call site, the bootstrap method is invoked with parameter |
|
173 |
* types {@code MethodHandles.Lookup}, {@code String}, {@code MethodType}, and the types |
|
174 |
* of any static arguments; the return type is {@code CallSite}. For a |
|
175 |
* dynamically-computed constant, the bootstrap method is invoked with parameter types |
|
176 |
* {@code MethodHandles.Lookup}, {@code String}, {@code Class}, and the types of any |
|
177 |
* static arguments; the return type is the type represented by the {@code Class}. |
|
178 |
* |
|
179 |
* Because {@link java.lang.invoke.MethodHandle#invoke MethodHandle.invoke} allows for |
|
180 |
* adaptations between the invoked method type and the method handle's method type, |
|
181 |
* there is flexibility in the declaration of the bootstrap method. |
|
9752
88ab34b6da6d
7032323: code changes for JSR 292 EG adjustments to API, through Public Review
jrose
parents:
9645
diff
changeset
|
182 |
* For example, the first argument could be {@code Object} |
88ab34b6da6d
7032323: code changes for JSR 292 EG adjustments to API, through Public Review
jrose
parents:
9645
diff
changeset
|
183 |
* instead of {@code MethodHandles.Lookup}, and the return type |
88ab34b6da6d
7032323: code changes for JSR 292 EG adjustments to API, through Public Review
jrose
parents:
9645
diff
changeset
|
184 |
* could also be {@code Object} instead of {@code CallSite}. |
88ab34b6da6d
7032323: code changes for JSR 292 EG adjustments to API, through Public Review
jrose
parents:
9645
diff
changeset
|
185 |
* (Note that the types and number of the stacked arguments limit |
88ab34b6da6d
7032323: code changes for JSR 292 EG adjustments to API, through Public Review
jrose
parents:
9645
diff
changeset
|
186 |
* the legal kinds of bootstrap methods to appropriately typed |
48826 | 187 |
* static methods and constructors.) |
7555
a279ebc3b25c
6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents:
7051
diff
changeset
|
188 |
* <p> |
48826 | 189 |
* If a pushed value is a primitive type, it may be converted to a reference by boxing conversion. |
8345
9e2483e6cfab
7013417: JSR 292 needs to support variadic method handle calls
jrose
parents:
7668
diff
changeset
|
190 |
* If the bootstrap method is a variable arity method (its modifier bit {@code 0x0080} is set), |
9e2483e6cfab
7013417: JSR 292 needs to support variadic method handle calls
jrose
parents:
7668
diff
changeset
|
191 |
* then some or all of the arguments specified here may be collected into a trailing array parameter. |
9e2483e6cfab
7013417: JSR 292 needs to support variadic method handle calls
jrose
parents:
7668
diff
changeset
|
192 |
* (This is not a special rule, but rather a useful consequence of the interaction |
9e2483e6cfab
7013417: JSR 292 needs to support variadic method handle calls
jrose
parents:
7668
diff
changeset
|
193 |
* between {@code CONSTANT_MethodHandle} constants, the modifier bit for variable arity methods, |
9752
88ab34b6da6d
7032323: code changes for JSR 292 EG adjustments to API, through Public Review
jrose
parents:
9645
diff
changeset
|
194 |
* and the {@link java.lang.invoke.MethodHandle#asVarargsCollector asVarargsCollector} transformation.) |
8345
9e2483e6cfab
7013417: JSR 292 needs to support variadic method handle calls
jrose
parents:
7668
diff
changeset
|
195 |
* <p> |
48826 | 196 |
* Given these rules, here are examples of legal bootstrap method declarations for |
197 |
* dynamically-computed call sites, given various numbers {@code N} of extra arguments. |
|
46148
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
198 |
* The first row (marked {@code *}) will work for any number of extra arguments. |
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
199 |
* <table class="plain" style="vertical-align:top"> |
45437 | 200 |
* <caption style="display:none">Static argument types</caption> |
46148
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
201 |
* <thead> |
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
202 |
* <tr><th scope="col">N</th><th scope="col">Sample bootstrap method</th></tr> |
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
203 |
* </thead> |
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
204 |
* <tbody> |
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
205 |
* <tr><th scope="row" style="font-weight:normal; vertical-align:top">*</th><td> |
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
206 |
* <ul style="list-style:none; padding-left: 0; margin:0"> |
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
207 |
* <li><code>CallSite bootstrap(Lookup caller, String name, MethodType type, Object... args)</code> |
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
208 |
* <li><code>CallSite bootstrap(Object... args)</code> |
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
209 |
* <li><code>CallSite bootstrap(Object caller, Object... nameAndTypeWithArgs)</code> |
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
210 |
* </ul></td></tr> |
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
211 |
* <tr><th scope="row" style="font-weight:normal; vertical-align:top">0</th><td> |
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
212 |
* <ul style="list-style:none; padding-left: 0; margin:0"> |
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
213 |
* <li><code>CallSite bootstrap(Lookup caller, String name, MethodType type)</code> |
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
214 |
* <li><code>CallSite bootstrap(Lookup caller, Object... nameAndType)</code> |
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
215 |
* </ul></td></tr> |
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
216 |
* <tr><th scope="row" style="font-weight:normal; vertical-align:top">1</th><td> |
45437 | 217 |
* <code>CallSite bootstrap(Lookup caller, String name, MethodType type, Object arg)</code></td></tr> |
46148
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
218 |
* <tr><th scope="row" style="font-weight:normal; vertical-align:top">2</th><td> |
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
219 |
* <ul style="list-style:none; padding-left: 0; margin:0"> |
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
220 |
* <li><code>CallSite bootstrap(Lookup caller, String name, MethodType type, Object... args)</code> |
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
221 |
* <li><code>CallSite bootstrap(Lookup caller, String name, MethodType type, String... args)</code> |
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
222 |
* <li><code>CallSite bootstrap(Lookup caller, String name, MethodType type, String x, int y)</code> |
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
223 |
* </ul></td></tr> |
6d8e27cd2f1e
8186052: Fix a11y and HTML issues in the java.base/java.lang[.*] packages
jjg
parents:
45437
diff
changeset
|
224 |
* </tbody> |
7555
a279ebc3b25c
6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents:
7051
diff
changeset
|
225 |
* </table> |
8345
9e2483e6cfab
7013417: JSR 292 needs to support variadic method handle calls
jrose
parents:
7668
diff
changeset
|
226 |
* The last example assumes that the extra arguments are of type |
47250
a0f26f0da4f1
8185993: MethodHandle.invokeWithArguments jumbo-arity
jrose
parents:
47216
diff
changeset
|
227 |
* {@code String} and {@code Integer} (or {@code int}), respectively. |
8345
9e2483e6cfab
7013417: JSR 292 needs to support variadic method handle calls
jrose
parents:
7668
diff
changeset
|
228 |
* The second-to-last example assumes that all extra arguments are of type |
47250
a0f26f0da4f1
8185993: MethodHandle.invokeWithArguments jumbo-arity
jrose
parents:
47216
diff
changeset
|
229 |
* {@code String}. |
8345
9e2483e6cfab
7013417: JSR 292 needs to support variadic method handle calls
jrose
parents:
7668
diff
changeset
|
230 |
* The other examples work with all types of extra arguments. |
7555
a279ebc3b25c
6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents:
7051
diff
changeset
|
231 |
* <p> |
48826 | 232 |
* Since dynamically-computed constants can be provided as static arguments to bootstrap |
233 |
* methods, there are no limitations on the types of bootstrap arguments. |
|
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9752
diff
changeset
|
234 |
* However, arguments of type {@code boolean}, {@code byte}, {@code short}, or {@code char} |
48826 | 235 |
* cannot be <em>directly</em> supplied by {@code CONSTANT_Integer} |
236 |
* constant pool entries, since the {@code asType} conversions do |
|
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9752
diff
changeset
|
237 |
* not perform the necessary narrowing primitive conversions. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9752
diff
changeset
|
238 |
* <p> |
48826 | 239 |
* In the above examples, the return type is always {@code CallSite}, |
240 |
* but that is not a necessary feature of bootstrap methods. |
|
241 |
* In the case of a dynamically-computed call site, the only requirement is that |
|
242 |
* the return type of the bootstrap method must be convertible |
|
243 |
* (using the {@code asType} conversions) to {@code CallSite}, which |
|
244 |
* means the bootstrap method return type might be {@code Object} or |
|
245 |
* {@code ConstantCallSite}. |
|
246 |
* In the case of a dynamically-resolved constant, the return type of the bootstrap |
|
247 |
* method must be convertible to the type of the constant, as |
|
248 |
* represented by its field type descriptor. For example, if the |
|
249 |
* dynamic constant has a field type descriptor of {@code "C"} |
|
250 |
* ({@code char}) then the bootstrap method return type could be |
|
251 |
* {@code Object}, {@code Character}, or {@code char}, but not |
|
252 |
* {@code int} or {@code Integer}. |
|
7557
06bbd3ae0835
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7555
diff
changeset
|
253 |
* |
2707
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
254 |
* @author John Rose, JSR 292 EG |
8822
8145ab9f5f86
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
8349
diff
changeset
|
255 |
* @since 1.7 |
2707
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
256 |
*/ |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
257 |
|
8822
8145ab9f5f86
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
8349
diff
changeset
|
258 |
package java.lang.invoke; |