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

[jira] Created: (HARMONY-1175) [classlib][io] BufferedWriter.write() exception behavior differ from RI

[classlib][io] BufferedWriter.write() exception behavior differ from RI
-----------------------------------------------------------------------

                 Key: HARMONY-1175
                 URL: http://issues.apache.org/jira/browse/HARMONY-1175
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Denis Kishenko


1. Harmony implementation of BufferedWriter.write(String, int, int) throws an exception if len is negative while spec says (and RI follows it)
public void write(String s, int off, int len) throws IOExceptionWrite a portion of a String. 
If the value of the len parameter is negative then no characters are written. This is contrary to the specification of this method in the superclass, which requires that an IndexOutOfBoundsException be thrown. 

2. Harmony implementation of BufferedWriter.write(char[], int, int)  throws ArrayIndexOutOfBoundsException while RI throws IndexOutOfBoundsException.

=========================== Test ===============================
import java.io.*;
public class bug9588 {

    static void test(String name, Object buf, int offset, int count) {
        try {
            System.err.println(name);
            ByteArrayOutputStream baos = new ByteArrayOutputStream(200);
            OutputStreamWriter osw = new OutputStreamWriter(baos);
            BufferedWriter bw = new BufferedWriter((Writer)osw);
            if (buf instanceof String) {
                bw.write((String)buf, offset, count);
            } else {
                bw.write((char[])buf, offset, count);
            }
            bw.flush();
            System.err.println("Number of written chars: " +(baos.toByteArray()).length);
        } catch (Exception e) {
            e.printStackTrace();
        }  
    }

    public static void main (String [] args) throws Exception  {
        String str = "abcde";
        char[] ch = new char[] {'a', 'b', 'c', 'd', 'e'}; 
        test("1", str, 1, -1);
        test("2", str, -1, 1);
        test("3", str, -1, -1);
        test("4", str, 7, 1);
        test("5", str, 3, 4);        
        test("6", ch, 1, -1);
        test("7", ch, -1, 1);
        test("8", ch, -1, -1);
        test("9", ch, 7, 1);
        test("10", ch, 3, 4);        
    }
}

=================== Output ==========================

RI

1
Number of written chars: 0
2
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.String.getChars(II[CI)V(Unknown Source)
    at java.io.BufferedWriter.write(BufferedWriter.java:208)
    at bug9588.test(bug9588.java:12)
    at bug9588.main(bug9588.java:27)
3
Number of written chars: 0
4
java.lang.StringIndexOutOfBoundsException: String index out of range: 8
    at java.lang.String.getChars(II[CI)V(Unknown Source)
    at java.io.BufferedWriter.write(BufferedWriter.java:208)
    at bug9588.test(bug9588.java:12)
    at bug9588.main(bug9588.java:29)
5
java.lang.StringIndexOutOfBoundsException: String index out of range: 7
    at java.lang.String.getChars(II[CI)V(Unknown Source)
    at java.io.BufferedWriter.write(BufferedWriter.java:208)
    at bug9588.test(bug9588.java:12)
    at bug9588.main(bug9588.java:30)
6
java.lang.IndexOutOfBoundsException
    at java.io.BufferedWriter.write(BufferedWriter.java:160)
    at bug9588.test(bug9588.java:14)
    at bug9588.main(bug9588.java:31)
7
java.lang.IndexOutOfBoundsException
    at java.io.BufferedWriter.write(BufferedWriter.java:160)
    at bug9588.test(bug9588.java:14)
    at bug9588.main(bug9588.java:32)
8
java.lang.IndexOutOfBoundsException
    at java.io.BufferedWriter.write(BufferedWriter.java:160)
    at bug9588.test(bug9588.java:14)
    at bug9588.main(bug9588.java:33)
9
java.lang.IndexOutOfBoundsException
    at java.io.BufferedWriter.write(BufferedWriter.java:160)
    at bug9588.test(bug9588.java:14)
    at bug9588.main(bug9588.java:34)
10
java.lang.IndexOutOfBoundsException
    at java.io.BufferedWriter.write(BufferedWriter.java:160)
    at bug9588.test(bug9588.java:14)
    at bug9588.main(bug9588.java:35)

Harmony

1
java.lang.StringIndexOutOfBoundsException
    at java.io.BufferedWriter.write(BufferedWriter.java:291)
    at bug9588.test(bug9588.java:12)
    at bug9588.main(bug9588.java:26)
2
java.lang.StringIndexOutOfBoundsException
    at java.io.BufferedWriter.write(BufferedWriter.java:291)
    at bug9588.test(bug9588.java:12)
    at bug9588.main(bug9588.java:27)
3
java.lang.StringIndexOutOfBoundsException
    at java.io.BufferedWriter.write(BufferedWriter.java:291)
    at bug9588.test(bug9588.java:12)
    at bug9588.main(bug9588.java:28)
4
java.lang.StringIndexOutOfBoundsException
    at java.io.BufferedWriter.write(BufferedWriter.java:291)
    at bug9588.test(bug9588.java:12)
    at bug9588.main(bug9588.java:29)
5
java.lang.StringIndexOutOfBoundsException
    at java.io.BufferedWriter.write(BufferedWriter.java:291)
    at bug9588.test(bug9588.java:12)
    at bug9588.main(bug9588.java:30)
6
java.lang.ArrayIndexOutOfBoundsException
    at java.io.BufferedWriter.write(BufferedWriter.java:198)
    at bug9588.test(bug9588.java:14)
    at bug9588.main(bug9588.java:31)
7
java.lang.ArrayIndexOutOfBoundsException
    at java.io.BufferedWriter.write(BufferedWriter.java:198)
    at bug9588.test(bug9588.java:14)
    at bug9588.main(bug9588.java:32)
8
java.lang.ArrayIndexOutOfBoundsException
    at java.io.BufferedWriter.write(BufferedWriter.java:198)
    at bug9588.test(bug9588.java:14)
    at bug9588.main(bug9588.java:33)
9
java.lang.ArrayIndexOutOfBoundsException
    at java.io.BufferedWriter.write(BufferedWriter.java:198)
    at bug9588.test(bug9588.java:14)
    at bug9588.main(bug9588.java:34)
10
java.lang.ArrayIndexOutOfBoundsException
    at java.io.BufferedWriter.write(BufferedWriter.java:198)
    at bug9588.test(bug9588.java:14)
    at bug9588.main(bug9588.java:35)


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

        

Re: [jira] Created: (HARMONY-1175) [classlib][io] BufferedWriter.write() exception behavior differ from RI

Posted by Alexey Petrenko <al...@gmail.com>.
But this incompatibility will not break any software which is related
on RI's behaviour

2006/8/15, Denis Kishenko <dk...@gmail.com>:
> 2006/8/14, Alexey Petrenko <al...@gmail.com>:
> > > 2. Harmony implementation of BufferedWriter.write(char[], int, int)  throws ArrayIndexOutOfBoundsException while RI throws IndexOutOfBoundsException.
> > I think that this is not a problem since
> > ArrayIndexOutOfBoundsException is a subclass of
> > IndexOutOfBoundsException...
> In spite of this it's incompatibility with RI
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


-- 
Alexey A. Petrenko
Intel Middleware Products Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [jira] Created: (HARMONY-1175) [classlib][io] BufferedWriter.write() exception behavior differ from RI

Posted by Denis Kishenko <dk...@gmail.com>.
2006/8/14, Alexey Petrenko <al...@gmail.com>:
> > 2. Harmony implementation of BufferedWriter.write(char[], int, int)  throws ArrayIndexOutOfBoundsException while RI throws IndexOutOfBoundsException.
> I think that this is not a problem since
> ArrayIndexOutOfBoundsException is a subclass of
> IndexOutOfBoundsException...
In spite of this it's incompatibility with RI

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [jira] Created: (HARMONY-1175) [classlib][io] BufferedWriter.write() exception behavior differ from RI

Posted by Alexey Petrenko <al...@gmail.com>.
2006/8/14, Denis Kishenko (JIRA) <ji...@apache.org>:
> [classlib][io] BufferedWriter.write() exception behavior differ from RI
> -----------------------------------------------------------------------
>
>                 Key: HARMONY-1175
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1175
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Denis Kishenko
>
>
> 1. Harmony implementation of BufferedWriter.write(String, int, int) throws an exception if len is negative while spec says (and RI follows it)
> public void write(String s, int off, int len) throws IOExceptionWrite a portion of a String.
> If the value of the len parameter is negative then no characters are written. This is contrary to the specification of this method in the superclass, which requires that an IndexOutOfBoundsException be thrown.
>
> 2. Harmony implementation of BufferedWriter.write(char[], int, int)  throws ArrayIndexOutOfBoundsException while RI throws IndexOutOfBoundsException.
I think that this is not a problem since
ArrayIndexOutOfBoundsException is a subclass of
IndexOutOfBoundsException...

SY, Alexey

>
> =========================== Test ===============================
> import java.io.*;
> public class bug9588 {
>
>    static void test(String name, Object buf, int offset, int count) {
>        try {
>            System.err.println(name);
>            ByteArrayOutputStream baos = new ByteArrayOutputStream(200);
>            OutputStreamWriter osw = new OutputStreamWriter(baos);
>            BufferedWriter bw = new BufferedWriter((Writer)osw);
>            if (buf instanceof String) {
>                bw.write((String)buf, offset, count);
>            } else {
>                bw.write((char[])buf, offset, count);
>            }
>            bw.flush();
>            System.err.println("Number of written chars: " +(baos.toByteArray()).length);
>        } catch (Exception e) {
>            e.printStackTrace();
>        }
>    }
>
>    public static void main (String [] args) throws Exception  {
>        String str = "abcde";
>        char[] ch = new char[] {'a', 'b', 'c', 'd', 'e'};
>        test("1", str, 1, -1);
>        test("2", str, -1, 1);
>        test("3", str, -1, -1);
>        test("4", str, 7, 1);
>        test("5", str, 3, 4);
>        test("6", ch, 1, -1);
>        test("7", ch, -1, 1);
>        test("8", ch, -1, -1);
>        test("9", ch, 7, 1);
>        test("10", ch, 3, 4);
>    }
> }
>
> =================== Output ==========================
>
> RI
>
> 1
> Number of written chars: 0
> 2
> java.lang.StringIndexOutOfBoundsException: String index out of range: -1
>    at java.lang.String.getChars(II[CI)V(Unknown Source)
>    at java.io.BufferedWriter.write(BufferedWriter.java:208)
>    at bug9588.test(bug9588.java:12)
>    at bug9588.main(bug9588.java:27)
> 3
> Number of written chars: 0
> 4
> java.lang.StringIndexOutOfBoundsException: String index out of range: 8
>    at java.lang.String.getChars(II[CI)V(Unknown Source)
>    at java.io.BufferedWriter.write(BufferedWriter.java:208)
>    at bug9588.test(bug9588.java:12)
>    at bug9588.main(bug9588.java:29)
> 5
> java.lang.StringIndexOutOfBoundsException: String index out of range: 7
>    at java.lang.String.getChars(II[CI)V(Unknown Source)
>    at java.io.BufferedWriter.write(BufferedWriter.java:208)
>    at bug9588.test(bug9588.java:12)
>    at bug9588.main(bug9588.java:30)
> 6
> java.lang.IndexOutOfBoundsException
>    at java.io.BufferedWriter.write(BufferedWriter.java:160)
>    at bug9588.test(bug9588.java:14)
>    at bug9588.main(bug9588.java:31)
> 7
> java.lang.IndexOutOfBoundsException
>    at java.io.BufferedWriter.write(BufferedWriter.java:160)
>    at bug9588.test(bug9588.java:14)
>    at bug9588.main(bug9588.java:32)
> 8
> java.lang.IndexOutOfBoundsException
>    at java.io.BufferedWriter.write(BufferedWriter.java:160)
>    at bug9588.test(bug9588.java:14)
>    at bug9588.main(bug9588.java:33)
> 9
> java.lang.IndexOutOfBoundsException
>    at java.io.BufferedWriter.write(BufferedWriter.java:160)
>    at bug9588.test(bug9588.java:14)
>    at bug9588.main(bug9588.java:34)
> 10
> java.lang.IndexOutOfBoundsException
>    at java.io.BufferedWriter.write(BufferedWriter.java:160)
>    at bug9588.test(bug9588.java:14)
>    at bug9588.main(bug9588.java:35)
>
> Harmony
>
> 1
> java.lang.StringIndexOutOfBoundsException
>    at java.io.BufferedWriter.write(BufferedWriter.java:291)
>    at bug9588.test(bug9588.java:12)
>    at bug9588.main(bug9588.java:26)
> 2
> java.lang.StringIndexOutOfBoundsException
>    at java.io.BufferedWriter.write(BufferedWriter.java:291)
>    at bug9588.test(bug9588.java:12)
>    at bug9588.main(bug9588.java:27)
> 3
> java.lang.StringIndexOutOfBoundsException
>    at java.io.BufferedWriter.write(BufferedWriter.java:291)
>    at bug9588.test(bug9588.java:12)
>    at bug9588.main(bug9588.java:28)
> 4
> java.lang.StringIndexOutOfBoundsException
>    at java.io.BufferedWriter.write(BufferedWriter.java:291)
>    at bug9588.test(bug9588.java:12)
>    at bug9588.main(bug9588.java:29)
> 5
> java.lang.StringIndexOutOfBoundsException
>    at java.io.BufferedWriter.write(BufferedWriter.java:291)
>    at bug9588.test(bug9588.java:12)
>    at bug9588.main(bug9588.java:30)
> 6
> java.lang.ArrayIndexOutOfBoundsException
>    at java.io.BufferedWriter.write(BufferedWriter.java:198)
>    at bug9588.test(bug9588.java:14)
>    at bug9588.main(bug9588.java:31)
> 7
> java.lang.ArrayIndexOutOfBoundsException
>    at java.io.BufferedWriter.write(BufferedWriter.java:198)
>    at bug9588.test(bug9588.java:14)
>    at bug9588.main(bug9588.java:32)
> 8
> java.lang.ArrayIndexOutOfBoundsException
>    at java.io.BufferedWriter.write(BufferedWriter.java:198)
>    at bug9588.test(bug9588.java:14)
>    at bug9588.main(bug9588.java:33)
> 9
> java.lang.ArrayIndexOutOfBoundsException
>    at java.io.BufferedWriter.write(BufferedWriter.java:198)
>    at bug9588.test(bug9588.java:14)
>    at bug9588.main(bug9588.java:34)
> 10
> java.lang.ArrayIndexOutOfBoundsException
>    at java.io.BufferedWriter.write(BufferedWriter.java:198)
>    at bug9588.test(bug9588.java:14)
>    at bug9588.main(bug9588.java:35)
>
>
> --
> 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
>
>
>


-- 
Alexey A. Petrenko
Intel Middleware Products Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


[jira] Updated: (HARMONY-1175) [classlib][io] BufferedWriter.write() exception behavior differ from RI

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

Denis Kishenko updated HARMONY-1175:
------------------------------------

    Attachment: 1175-BufferedWriterTest.patch

> [classlib][io] BufferedWriter.write() exception behavior differ from RI
> -----------------------------------------------------------------------
>
>                 Key: HARMONY-1175
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1175
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Denis Kishenko
>         Attachments: 1175-BufferedWriter.patch, 1175-BufferedWriterTest.patch
>
>
> 1. Harmony implementation of BufferedWriter.write(String, int, int) throws an exception if len is negative while spec says (and RI follows it)
> public void write(String s, int off, int len) throws IOExceptionWrite a portion of a String. 
> If the value of the len parameter is negative then no characters are written. This is contrary to the specification of this method in the superclass, which requires that an IndexOutOfBoundsException be thrown. 
> 2. Harmony implementation of BufferedWriter.write(char[], int, int)  throws ArrayIndexOutOfBoundsException while RI throws IndexOutOfBoundsException.
> =========================== Test ===============================
> import java.io.*;
> public class bug9588 {
>     static void test(String name, Object buf, int offset, int count) {
>         try {
>             System.err.println(name);
>             ByteArrayOutputStream baos = new ByteArrayOutputStream(200);
>             OutputStreamWriter osw = new OutputStreamWriter(baos);
>             BufferedWriter bw = new BufferedWriter((Writer)osw);
>             if (buf instanceof String) {
>                 bw.write((String)buf, offset, count);
>             } else {
>                 bw.write((char[])buf, offset, count);
>             }
>             bw.flush();
>             System.err.println("Number of written chars: " +(baos.toByteArray()).length);
>         } catch (Exception e) {
>             e.printStackTrace();
>         }  
>     }
>     public static void main (String [] args) throws Exception  {
>         String str = "abcde";
>         char[] ch = new char[] {'a', 'b', 'c', 'd', 'e'}; 
>         test("1", str, 1, -1);
>         test("2", str, -1, 1);
>         test("3", str, -1, -1);
>         test("4", str, 7, 1);
>         test("5", str, 3, 4);        
>         test("6", ch, 1, -1);
>         test("7", ch, -1, 1);
>         test("8", ch, -1, -1);
>         test("9", ch, 7, 1);
>         test("10", ch, 3, 4);        
>     }
> }
> =================== Output ==========================
> RI
> 1
> Number of written chars: 0
> 2
> java.lang.StringIndexOutOfBoundsException: String index out of range: -1
>     at java.lang.String.getChars(II[CI)V(Unknown Source)
>     at java.io.BufferedWriter.write(BufferedWriter.java:208)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:27)
> 3
> Number of written chars: 0
> 4
> java.lang.StringIndexOutOfBoundsException: String index out of range: 8
>     at java.lang.String.getChars(II[CI)V(Unknown Source)
>     at java.io.BufferedWriter.write(BufferedWriter.java:208)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:29)
> 5
> java.lang.StringIndexOutOfBoundsException: String index out of range: 7
>     at java.lang.String.getChars(II[CI)V(Unknown Source)
>     at java.io.BufferedWriter.write(BufferedWriter.java:208)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:30)
> 6
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:31)
> 7
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:32)
> 8
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:33)
> 9
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:34)
> 10
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:35)
> Harmony
> 1
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:26)
> 2
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:27)
> 3
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:28)
> 4
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:29)
> 5
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:30)
> 6
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:31)
> 7
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:32)
> 8
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:33)
> 9
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:34)
> 10
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:35)

-- 
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-1175) [classlib][io] BufferedWriter.write() exception behavior differ from RI

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

It is no longer an issue in latest code (r448046)

> [classlib][io] BufferedWriter.write() exception behavior differ from RI
> -----------------------------------------------------------------------
>
>                 Key: HARMONY-1175
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1175
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Denis Kishenko
>         Attachments: 1175-BufferedWriter.patch, 1175-BufferedWriterTest.patch
>
>
> 1. Harmony implementation of BufferedWriter.write(String, int, int) throws an exception if len is negative while spec says (and RI follows it)
> public void write(String s, int off, int len) throws IOExceptionWrite a portion of a String. 
> If the value of the len parameter is negative then no characters are written. This is contrary to the specification of this method in the superclass, which requires that an IndexOutOfBoundsException be thrown. 
> 2. Harmony implementation of BufferedWriter.write(char[], int, int)  throws ArrayIndexOutOfBoundsException while RI throws IndexOutOfBoundsException.
> =========================== Test ===============================
> import java.io.*;
> public class bug9588 {
>     static void test(String name, Object buf, int offset, int count) {
>         try {
>             System.err.println(name);
>             ByteArrayOutputStream baos = new ByteArrayOutputStream(200);
>             OutputStreamWriter osw = new OutputStreamWriter(baos);
>             BufferedWriter bw = new BufferedWriter((Writer)osw);
>             if (buf instanceof String) {
>                 bw.write((String)buf, offset, count);
>             } else {
>                 bw.write((char[])buf, offset, count);
>             }
>             bw.flush();
>             System.err.println("Number of written chars: " +(baos.toByteArray()).length);
>         } catch (Exception e) {
>             e.printStackTrace();
>         }  
>     }
>     public static void main (String [] args) throws Exception  {
>         String str = "abcde";
>         char[] ch = new char[] {'a', 'b', 'c', 'd', 'e'}; 
>         test("1", str, 1, -1);
>         test("2", str, -1, 1);
>         test("3", str, -1, -1);
>         test("4", str, 7, 1);
>         test("5", str, 3, 4);        
>         test("6", ch, 1, -1);
>         test("7", ch, -1, 1);
>         test("8", ch, -1, -1);
>         test("9", ch, 7, 1);
>         test("10", ch, 3, 4);        
>     }
> }
> =================== Output ==========================
> RI
> 1
> Number of written chars: 0
> 2
> java.lang.StringIndexOutOfBoundsException: String index out of range: -1
>     at java.lang.String.getChars(II[CI)V(Unknown Source)
>     at java.io.BufferedWriter.write(BufferedWriter.java:208)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:27)
> 3
> Number of written chars: 0
> 4
> java.lang.StringIndexOutOfBoundsException: String index out of range: 8
>     at java.lang.String.getChars(II[CI)V(Unknown Source)
>     at java.io.BufferedWriter.write(BufferedWriter.java:208)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:29)
> 5
> java.lang.StringIndexOutOfBoundsException: String index out of range: 7
>     at java.lang.String.getChars(II[CI)V(Unknown Source)
>     at java.io.BufferedWriter.write(BufferedWriter.java:208)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:30)
> 6
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:31)
> 7
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:32)
> 8
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:33)
> 9
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:34)
> 10
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:35)
> Harmony
> 1
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:26)
> 2
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:27)
> 3
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:28)
> 4
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:29)
> 5
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:30)
> 6
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:31)
> 7
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:32)
> 8
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:33)
> 9
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:34)
> 10
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:35)

-- 
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-1175) [classlib][io] BufferedWriter.write() exception behavior differ from RI

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

Denis Kishenko updated HARMONY-1175:
------------------------------------

    Attachment: 1175-BufferedWriter.patch

patch+test

> [classlib][io] BufferedWriter.write() exception behavior differ from RI
> -----------------------------------------------------------------------
>
>                 Key: HARMONY-1175
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1175
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Denis Kishenko
>         Attachments: 1175-BufferedWriter.patch, 1175-BufferedWriterTest.patch
>
>
> 1. Harmony implementation of BufferedWriter.write(String, int, int) throws an exception if len is negative while spec says (and RI follows it)
> public void write(String s, int off, int len) throws IOExceptionWrite a portion of a String. 
> If the value of the len parameter is negative then no characters are written. This is contrary to the specification of this method in the superclass, which requires that an IndexOutOfBoundsException be thrown. 
> 2. Harmony implementation of BufferedWriter.write(char[], int, int)  throws ArrayIndexOutOfBoundsException while RI throws IndexOutOfBoundsException.
> =========================== Test ===============================
> import java.io.*;
> public class bug9588 {
>     static void test(String name, Object buf, int offset, int count) {
>         try {
>             System.err.println(name);
>             ByteArrayOutputStream baos = new ByteArrayOutputStream(200);
>             OutputStreamWriter osw = new OutputStreamWriter(baos);
>             BufferedWriter bw = new BufferedWriter((Writer)osw);
>             if (buf instanceof String) {
>                 bw.write((String)buf, offset, count);
>             } else {
>                 bw.write((char[])buf, offset, count);
>             }
>             bw.flush();
>             System.err.println("Number of written chars: " +(baos.toByteArray()).length);
>         } catch (Exception e) {
>             e.printStackTrace();
>         }  
>     }
>     public static void main (String [] args) throws Exception  {
>         String str = "abcde";
>         char[] ch = new char[] {'a', 'b', 'c', 'd', 'e'}; 
>         test("1", str, 1, -1);
>         test("2", str, -1, 1);
>         test("3", str, -1, -1);
>         test("4", str, 7, 1);
>         test("5", str, 3, 4);        
>         test("6", ch, 1, -1);
>         test("7", ch, -1, 1);
>         test("8", ch, -1, -1);
>         test("9", ch, 7, 1);
>         test("10", ch, 3, 4);        
>     }
> }
> =================== Output ==========================
> RI
> 1
> Number of written chars: 0
> 2
> java.lang.StringIndexOutOfBoundsException: String index out of range: -1
>     at java.lang.String.getChars(II[CI)V(Unknown Source)
>     at java.io.BufferedWriter.write(BufferedWriter.java:208)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:27)
> 3
> Number of written chars: 0
> 4
> java.lang.StringIndexOutOfBoundsException: String index out of range: 8
>     at java.lang.String.getChars(II[CI)V(Unknown Source)
>     at java.io.BufferedWriter.write(BufferedWriter.java:208)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:29)
> 5
> java.lang.StringIndexOutOfBoundsException: String index out of range: 7
>     at java.lang.String.getChars(II[CI)V(Unknown Source)
>     at java.io.BufferedWriter.write(BufferedWriter.java:208)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:30)
> 6
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:31)
> 7
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:32)
> 8
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:33)
> 9
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:34)
> 10
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:35)
> Harmony
> 1
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:26)
> 2
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:27)
> 3
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:28)
> 4
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:29)
> 5
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:30)
> 6
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:31)
> 7
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:32)
> 8
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:33)
> 9
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:34)
> 10
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:35)

-- 
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] Resolved: (HARMONY-1175) [classlib][io] BufferedWriter.write() exception behavior differ from RI

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

Paulex Yang resolved HARMONY-1175.
----------------------------------

    Resolution: Cannot Reproduce

Tony, thank you to look at it.

Denis, please verify if the issue doesn't exist now, thank you.

> [classlib][io] BufferedWriter.write() exception behavior differ from RI
> -----------------------------------------------------------------------
>
>                 Key: HARMONY-1175
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1175
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Denis Kishenko
>         Attachments: 1175-BufferedWriter.patch, 1175-BufferedWriterTest.patch
>
>
> 1. Harmony implementation of BufferedWriter.write(String, int, int) throws an exception if len is negative while spec says (and RI follows it)
> public void write(String s, int off, int len) throws IOExceptionWrite a portion of a String. 
> If the value of the len parameter is negative then no characters are written. This is contrary to the specification of this method in the superclass, which requires that an IndexOutOfBoundsException be thrown. 
> 2. Harmony implementation of BufferedWriter.write(char[], int, int)  throws ArrayIndexOutOfBoundsException while RI throws IndexOutOfBoundsException.
> =========================== Test ===============================
> import java.io.*;
> public class bug9588 {
>     static void test(String name, Object buf, int offset, int count) {
>         try {
>             System.err.println(name);
>             ByteArrayOutputStream baos = new ByteArrayOutputStream(200);
>             OutputStreamWriter osw = new OutputStreamWriter(baos);
>             BufferedWriter bw = new BufferedWriter((Writer)osw);
>             if (buf instanceof String) {
>                 bw.write((String)buf, offset, count);
>             } else {
>                 bw.write((char[])buf, offset, count);
>             }
>             bw.flush();
>             System.err.println("Number of written chars: " +(baos.toByteArray()).length);
>         } catch (Exception e) {
>             e.printStackTrace();
>         }  
>     }
>     public static void main (String [] args) throws Exception  {
>         String str = "abcde";
>         char[] ch = new char[] {'a', 'b', 'c', 'd', 'e'}; 
>         test("1", str, 1, -1);
>         test("2", str, -1, 1);
>         test("3", str, -1, -1);
>         test("4", str, 7, 1);
>         test("5", str, 3, 4);        
>         test("6", ch, 1, -1);
>         test("7", ch, -1, 1);
>         test("8", ch, -1, -1);
>         test("9", ch, 7, 1);
>         test("10", ch, 3, 4);        
>     }
> }
> =================== Output ==========================
> RI
> 1
> Number of written chars: 0
> 2
> java.lang.StringIndexOutOfBoundsException: String index out of range: -1
>     at java.lang.String.getChars(II[CI)V(Unknown Source)
>     at java.io.BufferedWriter.write(BufferedWriter.java:208)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:27)
> 3
> Number of written chars: 0
> 4
> java.lang.StringIndexOutOfBoundsException: String index out of range: 8
>     at java.lang.String.getChars(II[CI)V(Unknown Source)
>     at java.io.BufferedWriter.write(BufferedWriter.java:208)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:29)
> 5
> java.lang.StringIndexOutOfBoundsException: String index out of range: 7
>     at java.lang.String.getChars(II[CI)V(Unknown Source)
>     at java.io.BufferedWriter.write(BufferedWriter.java:208)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:30)
> 6
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:31)
> 7
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:32)
> 8
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:33)
> 9
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:34)
> 10
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:35)
> Harmony
> 1
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:26)
> 2
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:27)
> 3
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:28)
> 4
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:29)
> 5
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:30)
> 6
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:31)
> 7
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:32)
> 8
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:33)
> 9
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:34)
> 10
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:35)

-- 
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] Closed: (HARMONY-1175) [classlib][io] BufferedWriter.write() exception behavior differ from RI

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

Paulex Yang closed HARMONY-1175.
--------------------------------

    Assignee: Paulex Yang

Verified by Denis.

> [classlib][io] BufferedWriter.write() exception behavior differ from RI
> -----------------------------------------------------------------------
>
>                 Key: HARMONY-1175
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1175
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Denis Kishenko
>         Assigned To: Paulex Yang
>         Attachments: 1175-BufferedWriter.patch, 1175-BufferedWriterTest.patch
>
>
> 1. Harmony implementation of BufferedWriter.write(String, int, int) throws an exception if len is negative while spec says (and RI follows it)
> public void write(String s, int off, int len) throws IOExceptionWrite a portion of a String. 
> If the value of the len parameter is negative then no characters are written. This is contrary to the specification of this method in the superclass, which requires that an IndexOutOfBoundsException be thrown. 
> 2. Harmony implementation of BufferedWriter.write(char[], int, int)  throws ArrayIndexOutOfBoundsException while RI throws IndexOutOfBoundsException.
> =========================== Test ===============================
> import java.io.*;
> public class bug9588 {
>     static void test(String name, Object buf, int offset, int count) {
>         try {
>             System.err.println(name);
>             ByteArrayOutputStream baos = new ByteArrayOutputStream(200);
>             OutputStreamWriter osw = new OutputStreamWriter(baos);
>             BufferedWriter bw = new BufferedWriter((Writer)osw);
>             if (buf instanceof String) {
>                 bw.write((String)buf, offset, count);
>             } else {
>                 bw.write((char[])buf, offset, count);
>             }
>             bw.flush();
>             System.err.println("Number of written chars: " +(baos.toByteArray()).length);
>         } catch (Exception e) {
>             e.printStackTrace();
>         }  
>     }
>     public static void main (String [] args) throws Exception  {
>         String str = "abcde";
>         char[] ch = new char[] {'a', 'b', 'c', 'd', 'e'}; 
>         test("1", str, 1, -1);
>         test("2", str, -1, 1);
>         test("3", str, -1, -1);
>         test("4", str, 7, 1);
>         test("5", str, 3, 4);        
>         test("6", ch, 1, -1);
>         test("7", ch, -1, 1);
>         test("8", ch, -1, -1);
>         test("9", ch, 7, 1);
>         test("10", ch, 3, 4);        
>     }
> }
> =================== Output ==========================
> RI
> 1
> Number of written chars: 0
> 2
> java.lang.StringIndexOutOfBoundsException: String index out of range: -1
>     at java.lang.String.getChars(II[CI)V(Unknown Source)
>     at java.io.BufferedWriter.write(BufferedWriter.java:208)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:27)
> 3
> Number of written chars: 0
> 4
> java.lang.StringIndexOutOfBoundsException: String index out of range: 8
>     at java.lang.String.getChars(II[CI)V(Unknown Source)
>     at java.io.BufferedWriter.write(BufferedWriter.java:208)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:29)
> 5
> java.lang.StringIndexOutOfBoundsException: String index out of range: 7
>     at java.lang.String.getChars(II[CI)V(Unknown Source)
>     at java.io.BufferedWriter.write(BufferedWriter.java:208)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:30)
> 6
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:31)
> 7
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:32)
> 8
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:33)
> 9
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:34)
> 10
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:35)
> Harmony
> 1
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:26)
> 2
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:27)
> 3
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:28)
> 4
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:29)
> 5
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:30)
> 6
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:31)
> 7
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:32)
> 8
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:33)
> 9
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:34)
> 10
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:35)

-- 
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-1175) [classlib][io] BufferedWriter.write() exception behavior differ from RI

Posted by "Denis Kishenko (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-1175?page=comments#action_12437567 ] 
            
Denis Kishenko commented on HARMONY-1175:
-----------------------------------------

Tony, thanks
Now our results the same as RI

Verified

> [classlib][io] BufferedWriter.write() exception behavior differ from RI
> -----------------------------------------------------------------------
>
>                 Key: HARMONY-1175
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1175
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Denis Kishenko
>         Attachments: 1175-BufferedWriter.patch, 1175-BufferedWriterTest.patch
>
>
> 1. Harmony implementation of BufferedWriter.write(String, int, int) throws an exception if len is negative while spec says (and RI follows it)
> public void write(String s, int off, int len) throws IOExceptionWrite a portion of a String. 
> If the value of the len parameter is negative then no characters are written. This is contrary to the specification of this method in the superclass, which requires that an IndexOutOfBoundsException be thrown. 
> 2. Harmony implementation of BufferedWriter.write(char[], int, int)  throws ArrayIndexOutOfBoundsException while RI throws IndexOutOfBoundsException.
> =========================== Test ===============================
> import java.io.*;
> public class bug9588 {
>     static void test(String name, Object buf, int offset, int count) {
>         try {
>             System.err.println(name);
>             ByteArrayOutputStream baos = new ByteArrayOutputStream(200);
>             OutputStreamWriter osw = new OutputStreamWriter(baos);
>             BufferedWriter bw = new BufferedWriter((Writer)osw);
>             if (buf instanceof String) {
>                 bw.write((String)buf, offset, count);
>             } else {
>                 bw.write((char[])buf, offset, count);
>             }
>             bw.flush();
>             System.err.println("Number of written chars: " +(baos.toByteArray()).length);
>         } catch (Exception e) {
>             e.printStackTrace();
>         }  
>     }
>     public static void main (String [] args) throws Exception  {
>         String str = "abcde";
>         char[] ch = new char[] {'a', 'b', 'c', 'd', 'e'}; 
>         test("1", str, 1, -1);
>         test("2", str, -1, 1);
>         test("3", str, -1, -1);
>         test("4", str, 7, 1);
>         test("5", str, 3, 4);        
>         test("6", ch, 1, -1);
>         test("7", ch, -1, 1);
>         test("8", ch, -1, -1);
>         test("9", ch, 7, 1);
>         test("10", ch, 3, 4);        
>     }
> }
> =================== Output ==========================
> RI
> 1
> Number of written chars: 0
> 2
> java.lang.StringIndexOutOfBoundsException: String index out of range: -1
>     at java.lang.String.getChars(II[CI)V(Unknown Source)
>     at java.io.BufferedWriter.write(BufferedWriter.java:208)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:27)
> 3
> Number of written chars: 0
> 4
> java.lang.StringIndexOutOfBoundsException: String index out of range: 8
>     at java.lang.String.getChars(II[CI)V(Unknown Source)
>     at java.io.BufferedWriter.write(BufferedWriter.java:208)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:29)
> 5
> java.lang.StringIndexOutOfBoundsException: String index out of range: 7
>     at java.lang.String.getChars(II[CI)V(Unknown Source)
>     at java.io.BufferedWriter.write(BufferedWriter.java:208)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:30)
> 6
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:31)
> 7
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:32)
> 8
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:33)
> 9
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:34)
> 10
> java.lang.IndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:160)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:35)
> Harmony
> 1
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:26)
> 2
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:27)
> 3
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:28)
> 4
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:29)
> 5
> java.lang.StringIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:291)
>     at bug9588.test(bug9588.java:12)
>     at bug9588.main(bug9588.java:30)
> 6
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:31)
> 7
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:32)
> 8
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:33)
> 9
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:34)
> 10
> java.lang.ArrayIndexOutOfBoundsException
>     at java.io.BufferedWriter.write(BufferedWriter.java:198)
>     at bug9588.test(bug9588.java:14)
>     at bug9588.main(bug9588.java:35)

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