132 (MethodHandle)argv[1], (MethodType)argv[2]); |
132 (MethodHandle)argv[1], (MethodType)argv[2]); |
133 } else if (isStringConcatFactoryBSM(bsmType) && argv.length >= 1) { |
133 } else if (isStringConcatFactoryBSM(bsmType) && argv.length >= 1) { |
134 String recipe = (String)argv[0]; |
134 String recipe = (String)argv[0]; |
135 Object[] shiftedArgs = Arrays.copyOfRange(argv, 1, argv.length); |
135 Object[] shiftedArgs = Arrays.copyOfRange(argv, 1, argv.length); |
136 result = (CallSite)bootstrapMethod.invokeExact(caller, name, (MethodType)type, recipe, shiftedArgs); |
136 result = (CallSite)bootstrapMethod.invokeExact(caller, name, (MethodType)type, recipe, shiftedArgs); |
|
137 } else if (isLambdaMetafactoryAltMetafactoryBSM(bsmType)) { |
|
138 result = (CallSite)bootstrapMethod.invokeExact(caller, name, (MethodType)type, argv); |
137 } else { |
139 } else { |
138 switch (argv.length) { |
140 switch (argv.length) { |
139 case 0: |
141 case 0: |
140 result = invoke(bootstrapMethod, caller, name, type); |
142 result = invoke(bootstrapMethod, caller, name, type); |
141 break; |
143 break; |
284 } |
286 } |
285 |
287 |
286 private static final MethodType LMF_INDY_MT = MethodType.methodType(CallSite.class, |
288 private static final MethodType LMF_INDY_MT = MethodType.methodType(CallSite.class, |
287 Lookup.class, String.class, MethodType.class, MethodType.class, MethodHandle.class, MethodType.class); |
289 Lookup.class, String.class, MethodType.class, MethodType.class, MethodHandle.class, MethodType.class); |
288 |
290 |
|
291 private static final MethodType LMF_ALT_MT = MethodType.methodType(CallSite.class, |
|
292 Lookup.class, String.class, MethodType.class, Object[].class); |
|
293 |
289 private static final MethodType LMF_CONDY_MT = MethodType.methodType(Object.class, |
294 private static final MethodType LMF_CONDY_MT = MethodType.methodType(Object.class, |
290 Lookup.class, String.class, Class.class, MethodType.class, MethodHandle.class, MethodType.class); |
295 Lookup.class, String.class, Class.class, MethodType.class, MethodHandle.class, MethodType.class); |
291 |
296 |
292 private static final MethodType SCF_MT = MethodType.methodType(CallSite.class, |
297 private static final MethodType SCF_MT = MethodType.methodType(CallSite.class, |
293 Lookup.class, String.class, MethodType.class, String.class, Object[].class); |
298 Lookup.class, String.class, MethodType.class, String.class, Object[].class); |
315 * {@see java.lang.invoke.LambdaMetafactory#metafactory( |
320 * {@see java.lang.invoke.LambdaMetafactory#metafactory( |
316 * MethodHandles.Lookup,String,MethodType,MethodType,MethodHandle,MethodType)} |
321 * MethodHandles.Lookup,String,MethodType,MethodType,MethodHandle,MethodType)} |
317 */ |
322 */ |
318 private static boolean isLambdaMetafactoryIndyBSM(MethodType bsmType) { |
323 private static boolean isLambdaMetafactoryIndyBSM(MethodType bsmType) { |
319 return bsmType == LMF_INDY_MT; |
324 return bsmType == LMF_INDY_MT; |
|
325 } |
|
326 |
|
327 /** |
|
328 * @return true iff the BSM method type exactly matches |
|
329 * {@see java.lang.invoke.LambdaMetafactory#altMetafactory( |
|
330 * MethodHandles.Lookup,String,MethodType,Object[])} |
|
331 */ |
|
332 private static boolean isLambdaMetafactoryAltMetafactoryBSM(MethodType bsmType) { |
|
333 return bsmType == LMF_ALT_MT; |
320 } |
334 } |
321 |
335 |
322 /** The JVM produces java.lang.Integer values to box |
336 /** The JVM produces java.lang.Integer values to box |
323 * CONSTANT_Integer boxes but does not intern them. |
337 * CONSTANT_Integer boxes but does not intern them. |
324 * Let's intern them. This is slightly wrong for |
338 * Let's intern them. This is slightly wrong for |