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

IllegalArgumentException thrown from position() is hard to understand

XMLWordPrintable

    • generic
    • generic

      A DESCRIPTION OF THE REQUEST :
      Position throws an IllegalArgumentException if the new position is > limit or < 0 but doesn't state what the new position is. The exception should contain the position in error in its message string.

      JUSTIFICATION :
      It is hard to debug position related bugs without this change.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      an IllegalArgumentException with a message like:

      String.format("New position is %d, but cannot be > %d or < 0", newPosition, limit)
      ACTUAL -
      An IllegalArgumentException with no message at all.

      ---------- BEGIN SOURCE ----------
      ByteBuffer.allocate(1).position(10);
      ---------- END SOURCE ----------

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: