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

(bf) CharBuffer.get(int) IndexOutOfBoundsException not thrown for index >= limit

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      beta3
    • CPU:
      sparc
    • OS:
      solaris_7
    • Verification:
      Verified

      Description

      Expected IndexOutOfBoundsException is not thrown for index >= limit in CharBuffer.get(int) and in StringCharBuffer.get(int)

      String source = "This is the string used to test the get() method";
      int size = source.length();
      CharBuffer c = CharBuffer.wrap(source);
      // For index = limit And index > limit.
      int limit = size/2;
      c.limit(limit);
      // test index = limit.
      int index = limit;
      try {
          System.out.println("limit is: "+c.limit());
          System.out.println("Index is: "+index);
          char ch = c.get(index);
          bReturn = false;
          System.out.println("Char at index is: "+ch);
          System.out.println("Error in get(int): IndexOutOfBoundsException not thrown for index = limit");
       }
       catch(IndexOutOfBoundsException e){
          System.out.println("Expected IndexOutOfBoundsException thrown for index = limit");
       }
       catch(Exception e){
         bReturn = false;
         String eName = e.toString();
         System.out.println("Error in get(int): "+eName+" thrown, expected IndexOutOfBoundsException");
       }

       // index > limit.
       // try to get a character whoes index is greater than size/2.
       index = limit + 1;
       try {
          System.out.println("limit is: "+c.limit());
          System.out.println("Index is: "+index);
          System.out.println("Char at index is: "+c.get(index));
          //c.get(index);
          bReturn = false;
          System.out.println("Error in get(int): IndexOutOfBoundsException not thrown for index > limit");
         }
        catch(IndexOutOfBoundsException e){
          System.out.println("Expected IndexOutOfBoundsException thrown for index > limit");
              }
              catch(Exception e){
               bReturn = false;
               String eName = e.toString();
               System.out.println("Error in get(int): "+eName+" thrown, expected IndexOutOfBoundsException");
              }

      ###@###.### 2001-10-04
      java version "1.4.0-beta3"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b82)
      Java HotSpot(TM) Client VM (build 1.4.0-beta3-b82, mixed mode)

      /net/sqesvr/export/xlt/libs/merlin/dev/testbase/src/libs_api_tests/common/java_nio/Buffer/CharBufferTest/CBGet/CBGet.java now passes on b82.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              iris Iris Clark
              Reporter:
              duke J. Duke (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: