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

(bf) IntBuffer: IllegalArgumentException thrown instead of IndexOutOfBoundsExcep

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 1.4.0
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_8

      Description

      The IntBuffer's wrap(int[],int.int) method should throw the IndexOutOfBoundsException for
      1)offset > array.length
      2)length > array.length - offset

      However it throws the IllegalArgumentException.
      The same problem exists for LongBuffer too.

      The following code shows the problem

             int[] intArray = new int[5];
             int size = intArray.length;
              try {
                  IntBuffer intBuf = IntBuffer.wrap(intArray,size,1);
              }catch (IndexOutOfBoundsException e) {
                  System.out.println("IndexOutOfBoundsException thrown");
              }catch(IllegalArgumentException e) {
                  System.out.println("IllegalArgumentException thrown");
              }catch(Exception e) {
                  System.out.println(e.toString()+" thrown");
              }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              iris Iris Clark
              Reporter:
              bhamehta Bhakti Mehta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: