Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8167966

MethodHandles.iteratedLoop fails with IAE in the case of correct arguments

XMLWordPrintable

      Please, observe MethodHandles.iteratedLoop(...) constraints for iterator, init and body.

      According to these constraints, three MethodHandle with following signatures should be accepted in abovementioned method :
      iterator=()Iterator
      init=()I
      body=(I,Object,I)I

      Let's look on their types. First I is locals state, Object is T, and second I is single loop argument. Init's parameter list should be effectively identical to loop parameter list (it is 'I'). The same requirements for iterator handle. However, following exception occurs:
      >> Exception in thread "main" java.lang.IllegalArgumentException: inferred first loop argument must be an array or inherit from Iterable: int

      Observing last constraint you can find constraint (first argument must be Iterable or array) in the case iterator=null. Here iterator is not null, so it is inapplicable.
      You can find complete code in Example0.java


      Was found on jdk9b140

        1. Example0.java
          0.6 kB
        2. Example1.java
          0.6 kB
        3. Example2.java
          0.6 kB

            psandoz Paul Sandoz
            asolodkaya Anastasiya Solodkaya (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: