harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Beyer (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-436) [classlib][luni] lang: Harmony should throw exceptions in a way similar to RI's one.
Date Tue, 09 May 2006 00:43:21 GMT
    [ http://issues.apache.org/jira/browse/HARMONY-436?page=comments#action_12378544 ] 

Nathan Beyer commented on HARMONY-436:
--------------------------------------

Most of the items pointed out for StringBuilder have TODO and FIXME comments in the test case
that discuss these [1]. There are a number of places that the specification doesn't say it
throw NPEs, but the assumption is that it will and all of the exceptions were matched based
on testing the RI. I wrote much of the StringBuilder code, and in cases where the spec wasn't
clear or the RI was contradictory, I tried to make the behavior consistent with how similar
StringBuffer and String APIs worked.

As an aside to this, in cases where the RI spec isn't documented completely, if Harmony code
implements it, then it should be documented in Harmony javadoc.

As for the actual patch, I disagree with most of it. Here are some specifics:
* Changing SIOOBE to IOOBE for StringBuilder#insert(int,char) is contradictory to all of the
other StringBuilder#insert methods, which throw SIOOBE. The code abides by the specification.
Also, if you look at StringBuffer's insert methods, this same documentation inconsistency
exists there too.
* In the StringBuffer change of SIOOBE to IOOBE, the last change drops the index value from
being passed to the exception.

What's the real value of these changes? The code already meets the specifications and the
compatability guidelines. The explicit null checks are okay, but if we're going to do this
for StringBuffer, then we should do this throughout the class.

-Nathan

[1] http://svn.apache.org/viewcvs.cgi/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/StringBuilderTest.java?view=markup

> [classlib][luni] lang: Harmony should throw exceptions in a way similar to RI's one.
> ------------------------------------------------------------------------------------
>
>          Key: HARMONY-436
>          URL: http://issues.apache.org/jira/browse/HARMONY-436
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Dmitry M. Kononov
>     Assignee: George Harley
>     Priority: Minor
>  Attachments: lang.cumulative.diff
>
> 1) java.lang.StringBuilder.insert(int offset, char c):
> Harmony throws StringIndexOutOfBoundsException when offset <0,
> while RI throws ArrayIndexOutOfBoundsException. 
> Specification mentions neither StringIndexOutOfBoundsException
> nor ArrayIndexOutOfBoundsException throwing, but says: 
> "Throws:
> IndexOutOfBoundsException - if the offset is invalid".
> 2) java.lang.StringBuffer.append(char[] str, int offset, int len):
> Harmony throws StringIndexOutOfBoundsException when str is not
> null, offset or/and len <0, while RI throws
> ArrayIndexOutOfBoundsException. Specification mentions neither
> StringIndexOutOfBoundsException nor
> ArrayIndexOutOfBoundsException throwing.
> 3) java.lang.StringBuffer.append(char[] str, int offset, int len):
> Harmony throws StringIndexOutOfBoundsException when str = null,
> offset or/and len <0, while RI throws NullPointerException.
> Specification mentions neither StringIndexOutOfBoundsException
> nor NullPointerException throwing.
> 4) java.lang.StringBuffer.getChars(int srcBegin,int srcEnd,char[] dst, int dstBegin):
> Harmony throws StringIndexOutOfBoundsException when dstBegin <0,
> while RI throws ArrayIndexOutOfBoundsException.
> Specification says:
> "Throws: 
> IndexOutOfBoundsException - if any of the following is true: 
> ...
> dstBegin is negative". 
> So RI does not comply with spec as well as Harmony does not comply with it.
> 5) java.lang.StringBuffer.insert(int offset, char c):
> Harmony throws StringIndexOutOfBoundsException when offset <0,
> while RI throws ArrayIndexOutOfBoundsException.
> Specification says:
> "The offset argument must be greater than or equal to 0 ... 
> Throws: 
> IndexOutOfBoundsException - if the offset is invalid."
> So RI does not comply with spec as well as Harmony does not comply with it.

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