JDK-8078290 : Customize adapted MethodHandle in MH.invoke() case
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang.invoke
  • Affected Version: 8u60,9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2015-04-21
  • Updated: 2015-09-29
  • Resolved: 2015-04-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u60Fixed 9 b64Fixed
Description
Customize adapted MethodHandle in MH.invoke() case.

Right now, generic invoker LambdaForm looks like:
invoke_002_MT=Lambda(a0:L,a1:L,a2:L)=>{              
    t3:L=Invokers.checkGenericType(a0:L,a2:L);
    t4:V=Invokers.checkCustomized(a0:L);
    t5:L=MethodHandle.invokeBasic(t3:L,a1:L);t5:L}
}
Customize a0, but invoke t3. a0 != t3 when asType conversion happens.

Should be:
Generic invoker LambdaForm should be:
invoke_002_MT=Lambda(a0:L,a1:L,a2:L)=>{              
    t3:L=Invokers.checkGenericType(a0:L,a2:L);
    t4:V=Invokers.checkCustomized(t3:L);
    t5:L=MethodHandle.invokeBasic(t3:L,a1:L);t5:L}
}
Comments
Suggested fix: diff --git a/src/java.base/share/classes/java/lang/invoke/Invokers.java b/src/java.base/share/classes/java/lang/invoke/Invokers.java --- a/src/java.base/share/classes/java/lang/invoke/Invokers.java +++ b/src/java.base/share/classes/java/lang/invoke/Invokers.java @@ -281,7 +281,7 @@ outArgs[0] = names[CHECK_TYPE]; } if (CHECK_CUSTOM != -1) { - names[CHECK_CUSTOM] = new Name(NF_checkCustomized, names[CALL_MH]); + names[CHECK_CUSTOM] = new Name(NF_checkCustomized, outArgs[0]); } names[LINKER_CALL] = new Name(outCallType, outArgs); lform = new LambdaForm(debugName, INARG_LIMIT, names);
21-04-2015