You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Ilya Okomin (JIRA)" <ji...@apache.org> on 2006/08/07 16:16:14 UTC

[jira] Created: (HARMONY-1082) [classlib][io]compatibility:java.io.BufferedOutputStream.write(byte[], int, int) throws ArrayIndexOutOfBoundsException while RI throws NullPointerException

[classlib][io]compatibility:java.io.BufferedOutputStream.write(byte[], int, int) throws ArrayIndexOutOfBoundsException while RI throws NullPointerException
-----------------------------------------------------------------------------------------------------------------------------------------------------------

                 Key: HARMONY-1082
                 URL: http://issues.apache.org/jira/browse/HARMONY-1082
             Project: Harmony
          Issue Type: Bug
          Components: Non-bug differences from RI
            Reporter: Ilya Okomin
            Priority: Trivial


J2SE API specifications for java.io.BufferedOutputStream.write(byte[], int, int) method says "Throws IOException - if an I/O error occurs."
Spec for the superclass java.io.OutputStream says that "If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown." 

Harmony throws ArrayIndexOutOfBoundsException while RI throws NullPointerException.

============== Test9422 .java ===================== 
import java.io.BufferedOutputStream;

public class Test9422 {

    public static void main(String[] argv) {
        BufferedOutputStream localBufferedOutputStream = new BufferedOutputStream(
                null, 1);
        byte[] array0 = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2 };

        try {
            localBufferedOutputStream.write(array0, 127, 1);
            System.out.println("Test filed!"); 
        } catch (IndexOutOfBoundsException e) { 
            System.out.println("Test passed: expected " + e); 
        } catch (Exception e) {
            System.out.println("Test filed: " + e); 
        }
        
        try {
            localBufferedOutputStream.write(array0, 5, 17);
            System.out.println("Test filed!"); 
        } catch (IndexOutOfBoundsException e) { 
            System.out.println("Test passed: expected " + e); 
        } catch (Exception e) {
            System.out.println("Test filed: " + e); 
        }

        try {
            localBufferedOutputStream.write(array0, -1, 5);
            System.out.println("Test filed!"); 
        } catch (IndexOutOfBoundsException e) { 
            System.out.println("Test passed: expected " + e); 
        } catch (Exception e) {
            System.out.println("Test filed: " + e); 
        }

        try {
            localBufferedOutputStream.write(array0, 1, -5);
            System.out.println("Test filed!"); 
        } catch (IndexOutOfBoundsException e) { 
            System.out.println("Test passed: expected " + e); 
        } catch (Exception e) {
            System.out.println("Test filed: " + e); 
        }

    }

}

========================================== 

Output:

Harmony: 
java version "1.5.0" 
pre-alpha : not complete or compatible
svn = r424571, (Jul 22 2006), Windows/ia32/msvc 1310, release build
http://incubator.apache.org/harmony

Test passed: expected java.lang.ArrayIndexOutOfBoundsException: Arguments out of bounds
Test passed: expected java.lang.ArrayIndexOutOfBoundsException: Arguments out of bounds
Test passed: expected java.lang.ArrayIndexOutOfBoundsException: Arguments out of bounds
Test passed: expected java.lang.ArrayIndexOutOfBoundsException: Arguments out of bounds

RI:
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
BEA WebLogic JRockit(R) (build dra-38972-20041208-2001-win-ia32, R25.0.0-75, GC: System optimized over throughput (initial strategy singleparpar))

Test filed: java.lang.NullPointerException
Test filed: java.lang.NullPointerException
Test filed: java.lang.NullPointerException
Test passed: expected java.lang.ArrayIndexOutOfBoundsException

-- 
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

        

[jira] Commented: (HARMONY-1082) [classlib][io]compatibility:java.io.BufferedOutputStream.write(byte[], int, int) throws ArrayIndexOutOfBoundsException while RI throws NullPointerException

Posted by "Tony Wu (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-1082?page=comments#action_12434582 ] 
            
Tony Wu commented on HARMONY-1082:
----------------------------------

IMO, it is not a non-bug difference.
In the testcase you have set the bufsize to 1, and when you write anything whose length is greater than 1, it will cause the outputstream to write something instead of just buffer it. so the NPE will be through firstly. It is reasonable.
I'll post a patch for that.

> [classlib][io]compatibility:java.io.BufferedOutputStream.write(byte[], int, int) throws ArrayIndexOutOfBoundsException while RI throws NullPointerException
> -----------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1082
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1082
>             Project: Harmony
>          Issue Type: Bug
>          Components: Non-bug differences from RI
>            Reporter: Ilya Okomin
>            Priority: Trivial
>
> J2SE API specifications for java.io.BufferedOutputStream.write(byte[], int, int) method says "Throws IOException - if an I/O error occurs."
> Spec for the superclass java.io.OutputStream says that "If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown." 
> Harmony throws ArrayIndexOutOfBoundsException while RI throws NullPointerException.
> ============== Test9422 .java ===================== 
> import java.io.BufferedOutputStream;
> public class Test9422 {
>     public static void main(String[] argv) {
>         BufferedOutputStream localBufferedOutputStream = new BufferedOutputStream(
>                 null, 1);
>         byte[] array0 = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2 };
>         try {
>             localBufferedOutputStream.write(array0, 127, 1);
>             System.out.println("Test filed!"); 
>         } catch (IndexOutOfBoundsException e) { 
>             System.out.println("Test passed: expected " + e); 
>         } catch (Exception e) {
>             System.out.println("Test filed: " + e); 
>         }
>         
>         try {
>             localBufferedOutputStream.write(array0, 5, 17);
>             System.out.println("Test filed!"); 
>         } catch (IndexOutOfBoundsException e) { 
>             System.out.println("Test passed: expected " + e); 
>         } catch (Exception e) {
>             System.out.println("Test filed: " + e); 
>         }
>         try {
>             localBufferedOutputStream.write(array0, -1, 5);
>             System.out.println("Test filed!"); 
>         } catch (IndexOutOfBoundsException e) { 
>             System.out.println("Test passed: expected " + e); 
>         } catch (Exception e) {
>             System.out.println("Test filed: " + e); 
>         }
>         try {
>             localBufferedOutputStream.write(array0, 1, -5);
>             System.out.println("Test filed!"); 
>         } catch (IndexOutOfBoundsException e) { 
>             System.out.println("Test passed: expected " + e); 
>         } catch (Exception e) {
>             System.out.println("Test filed: " + e); 
>         }
>     }
> }
> ========================================== 
> Output:
> Harmony: 
> java version "1.5.0" 
> pre-alpha : not complete or compatible
> svn = r424571, (Jul 22 2006), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Test passed: expected java.lang.ArrayIndexOutOfBoundsException: Arguments out of bounds
> Test passed: expected java.lang.ArrayIndexOutOfBoundsException: Arguments out of bounds
> Test passed: expected java.lang.ArrayIndexOutOfBoundsException: Arguments out of bounds
> Test passed: expected java.lang.ArrayIndexOutOfBoundsException: Arguments out of bounds
> RI:
> java version "1.5.0"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
> BEA WebLogic JRockit(R) (build dra-38972-20041208-2001-win-ia32, R25.0.0-75, GC: System optimized over throughput (initial strategy singleparpar))
> Test filed: java.lang.NullPointerException
> Test filed: java.lang.NullPointerException
> Test filed: java.lang.NullPointerException
> Test passed: expected java.lang.ArrayIndexOutOfBoundsException

-- 
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

        

[jira] Updated: (HARMONY-1082) [classlib][io]compatibility:java.io.BufferedOutputStream.write(byte[], int, int) throws ArrayIndexOutOfBoundsException while RI throws NullPointerException

Posted by "Tony Wu (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1082?page=all ]

Tony Wu updated HARMONY-1082:
-----------------------------

    Attachment: harmony-1082.diff

patch available

> [classlib][io]compatibility:java.io.BufferedOutputStream.write(byte[], int, int) throws ArrayIndexOutOfBoundsException while RI throws NullPointerException
> -----------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1082
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1082
>             Project: Harmony
>          Issue Type: Bug
>          Components: Non-bug differences from RI
>            Reporter: Ilya Okomin
>            Priority: Trivial
>         Attachments: harmony-1082.diff
>
>
> J2SE API specifications for java.io.BufferedOutputStream.write(byte[], int, int) method says "Throws IOException - if an I/O error occurs."
> Spec for the superclass java.io.OutputStream says that "If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown." 
> Harmony throws ArrayIndexOutOfBoundsException while RI throws NullPointerException.
> ============== Test9422 .java ===================== 
> import java.io.BufferedOutputStream;
> public class Test9422 {
>     public static void main(String[] argv) {
>         BufferedOutputStream localBufferedOutputStream = new BufferedOutputStream(
>                 null, 1);
>         byte[] array0 = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2 };
>         try {
>             localBufferedOutputStream.write(array0, 127, 1);
>             System.out.println("Test filed!"); 
>         } catch (IndexOutOfBoundsException e) { 
>             System.out.println("Test passed: expected " + e); 
>         } catch (Exception e) {
>             System.out.println("Test filed: " + e); 
>         }
>         
>         try {
>             localBufferedOutputStream.write(array0, 5, 17);
>             System.out.println("Test filed!"); 
>         } catch (IndexOutOfBoundsException e) { 
>             System.out.println("Test passed: expected " + e); 
>         } catch (Exception e) {
>             System.out.println("Test filed: " + e); 
>         }
>         try {
>             localBufferedOutputStream.write(array0, -1, 5);
>             System.out.println("Test filed!"); 
>         } catch (IndexOutOfBoundsException e) { 
>             System.out.println("Test passed: expected " + e); 
>         } catch (Exception e) {
>             System.out.println("Test filed: " + e); 
>         }
>         try {
>             localBufferedOutputStream.write(array0, 1, -5);
>             System.out.println("Test filed!"); 
>         } catch (IndexOutOfBoundsException e) { 
>             System.out.println("Test passed: expected " + e); 
>         } catch (Exception e) {
>             System.out.println("Test filed: " + e); 
>         }
>     }
> }
> ========================================== 
> Output:
> Harmony: 
> java version "1.5.0" 
> pre-alpha : not complete or compatible
> svn = r424571, (Jul 22 2006), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Test passed: expected java.lang.ArrayIndexOutOfBoundsException: Arguments out of bounds
> Test passed: expected java.lang.ArrayIndexOutOfBoundsException: Arguments out of bounds
> Test passed: expected java.lang.ArrayIndexOutOfBoundsException: Arguments out of bounds
> Test passed: expected java.lang.ArrayIndexOutOfBoundsException: Arguments out of bounds
> RI:
> java version "1.5.0"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
> BEA WebLogic JRockit(R) (build dra-38972-20041208-2001-win-ia32, R25.0.0-75, GC: System optimized over throughput (initial strategy singleparpar))
> Test filed: java.lang.NullPointerException
> Test filed: java.lang.NullPointerException
> Test filed: java.lang.NullPointerException
> Test passed: expected java.lang.ArrayIndexOutOfBoundsException

-- 
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