JDK-8156065 : MethodHandles.countedLoop() creates wrong resulting method handle type
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: java.lang.invoke
  • Priority: P3
  • Status: Resolved
  • Resolution: Cannot Reproduce
  • Submitted: 2016-05-04
  • Updated: 2016-06-21
  • Resolved: 2016-06-21
Description
MethodHandles.countedLoop(MH, MH, MH, MH) creates method handle with wrong return type, e.g. 
start=()int
end=()int
init=null
body=(int)String
Should result with void method handle (according to countedLoop documentation and generic loop documentation both).
Expected result ()void, actual ()String.

The same situation occurred with MethodHandles.countedLoop(MH, MH, MH) and MethodHandles.iteratedLoop(...). 

Example for iteratedLoop -  Failures1.java
Example for countedLoop(...) - Failures0.java
Found on jdk9_b116, tests are under development
Comments
Failures0 yields this error message: Exception in thread "main" java.lang.IllegalArgumentException: actual and expected body signatures must match: (int)String != (int)void at java.lang.invoke.MethodHandleStatics.newIllegalArgumentException(java.base@9-internal/MethodHandleStatics.java:110) at java.lang.invoke.MethodHandles.misMatchedTypes(java.base@9-internal/MethodHandles.java:3887) at java.lang.invoke.MethodHandles.checkCountedLoop(java.base@9-internal/MethodHandles.java:4664) at java.lang.invoke.MethodHandles.countedLoop(java.base@9-internal/MethodHandles.java:4620) at Failures0.main(Failures0.java:14) Failures1 yields this error message: Exception in thread "main" java.lang.IllegalArgumentException: body types (regard parameter types after index 0, and result type) must match: (String,int)int != ()void at java.lang.invoke.MethodHandleStatics.newIllegalArgumentException(java.base@9-internal/MethodHandleStatics.java:110) at java.lang.invoke.MethodHandles.misMatchedTypes(java.base@9-internal/MethodHandles.java:3887) at java.lang.invoke.MethodHandles.checkIteratedLoop(java.base@9-internal/MethodHandles.java:5060) at java.lang.invoke.MethodHandles.iteratedLoop(java.base@9-internal/MethodHandles.java:4768) at Failures1.main(Failures1.java:13) These are due to the more restrictive requirements imposed on the argument handles to loop combinators.
21-06-2016

With the new - and considerably more restrictive - API spec in place due to the ongoing work on JDK-8151179, these issues cannot be reproduced any more.
21-06-2016

Failing tests: api/java_lang/invoke/MethodHandles/CountedLoop/index.html#CountedLoop4ParamTests#lambda manWithNullInit api/java_lang/invoke/MethodHandles/CountedLoop/index.html#CountedLoop3ParamTests#lambdamanWithNullInit api/java_lang/invoke/MethodHandles/IteratedLoop/index.html#IteratedLoopTests[emptyIteratorNullInitReturnType] api/java_lang/invoke/MethodHandles/IteratedLoop/index.html#IteratedLoopTests[listReverserNullInitReturnType]
05-05-2016