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

(bf) Add meaningful detail strings to thrown IllegalArgumentExceptions

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 7
    • 1.4.2_02
    • core-libs
    • b12
    • x86
    • solaris_8
    • Not verified


      The IllegalArgumentExceptions thrown by java.nio.Buffer do not contain
      any text:

      $ grep "new IllegalArgumentException" Buffer.java
      throw new IllegalArgumentException();
      throw new IllegalArgumentException();
      throw new IllegalArgumentException();
      throw new IllegalArgumentException();

      It would be very helpful if the exceptions stated what the illegal value
      was, and why it was illegal. For example:

      "Position 189 is greater than limit 128"
      "Limit 256 is greater than capacity 64"

      Or heck, state the values of all relevant parameters and fields as
      Josh recomends in "Effective Java":

      "...the string representation of an exception should contain the
      values of all parameters and fields that contributed to the exception"

      Exceptions are often the first step in debugging a problem, and it's
      a huge benefit to have useful information in them.

      Even though this is not a severe bug, please consider addressing it
      soon as it's simple to fix and reaps large rewards.



            iris Iris Clark
            jdipol Joe Dipol
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: