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

MethodHandles.countedLoop/4 works incorrect for start/end = Integer.MAX_VALUE

XMLWordPrintable

      According to documentation loop should run (end - start) times from start to end - 1.

      Please, look at attached example. Considering countedLoop(x, y, ..., ...)
      it should run 0 times in the case y <= x. It works correctly in most cases, e.g. (1, 0) and (0, -10), etc.
      Following cases have unexpected behaviour
      1) (Integer.MAX_VALUE - 1, Integer,MAX_VALUE)
      2) (Integer.MAX_VALUE, any_integer)

      E.g. (Integer.MAX_VALUE, Integer.MIN_VALUE + 10) iterates 11 times.

      Two commented lines in the end of 'main' method will lead to huge output.


      Found on jdk9b131

            mhaupt Michael Haupt
            asolodkaya Anastasiya Solodkaya (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: