harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Svetlana Samoilenko (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HARMONY-377) java.io.RandomAccessFile.read/write(byte[] b,int off,int len) methods don't throw IndexOutOfBoundsException
Date Wed, 19 Apr 2006 05:17:18 GMT
     [ http://issues.apache.org/jira/browse/HARMONY-377?page=all ]

Svetlana Samoilenko updated HARMONY-377:
----------------------------------------

    Attachment: RandomAccessFile.diffs

patch

> java.io.RandomAccessFile.read/write(byte[] b,int off,int len) methods don't  throw IndexOutOfBoundsException
> ------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-377
>          URL: http://issues.apache.org/jira/browse/HARMONY-377
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Svetlana Samoilenko
>  Attachments: RandomAccessFile.diffs, RandomAccessFileTest.java
>
> java.io.RandomAccessFile.read(byte[] b,int off,int len) and write(byte[] b,int off,int
len) methods don't throw IndexOutOfBoundsException
> if off is negative, or len is negative, or off+len is greater than the length of the
array b.
> Code to reproduce:
> import java.io.File;
> import java.io.RandomAccessFile;
> import java.io.IOException;
> public class test {
>   public static void main(String[] args) throws IOException {
>         File file=File.createTempFile("two",null);
>         RandomAccessFile rfl= new RandomAccessFile(file,"rw");
>         try {            
>             rfl.write(new byte[1], -1, 1);
>             System.out.println("method write: IndexOutOfBoundsException must be thrown
if off <0");   
>         } catch (IndexOutOfBoundsException  e) {
>              // expected
>         }
>         try {                        
>             rfl.write(new byte[1], 0, -1);
>             System.out.println("method write: IndexOutOfBoundsException must be thrown
if len <0") ;  
>         } catch (IndexOutOfBoundsException  e) {
>             // expected
>         }
>         try {                        
>             rfl.write(new byte[1], 0, 5);
>             System.out.println("method write: IndexOutOfBoundsException must be thrown
if off+len > b.lengh"); 
>         } catch (IndexOutOfBoundsException  e) {
>             // expected
>         }
>         try {            
>             rfl.read(new byte[1], -1, 1);
>             System.out.println("method read: IndexOutOfBoundsException must be thrown
if off <0");   
>         } catch (IndexOutOfBoundsException  e) {
>              // expected
>         }
>         try {                        
>             rfl.read(new byte[1], 0, -1);
>             System.out.println("method read: IndexOutOfBoundsException must be thrown
if len <0") ;  
>         } catch (IndexOutOfBoundsException  e) {
>             // expected 
>         }
>         try {                        
>             rfl.read(new byte[1], 0, 5);
>             System.out.println("method read: IndexOutOfBoundsException must be thrown
if off+len > b.lengh"); 
>         } catch (IndexOutOfBoundsException  e) {
>             // expected
>         }
>     }
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message