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

[jira] Commented: (HARMONY-1033) [classlib][lang]compatibility: expected IndexOutOfBoundsException for Character.codePointAt

    [ http://issues.apache.org/jira/browse/HARMONY-1033?page=comments#action_12425114 ] 
            
Nathan Beyer commented on HARMONY-1033:
---------------------------------------

This seems like an extreme edge case. The code implements the specification and Harmony's results aren't surprising. I suggest bringing this up on the mailing list for additional feedback, as I'm not inclined to move forward with this change. The resulting code seems very awkward.

> [classlib][lang]compatibility: expected IndexOutOfBoundsException for  Character.codePointAt
> --------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1033
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1033
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Denis Kishenko
>         Assigned To: Nathan Beyer
>         Attachments: Character.patch, CharacterTest.patch
>
>
> Specs 1.5
> Methods throws 
>   NullPointerException - if a is null. 
>   IndexOutOfBoundsException - if offset or count is negative, or if offset + count is larger than the length of the given array.
> If first argument is null RI throws NPE only in the second test, it's strange, but we have to follow.
> public class bug9276 {
>     public static void main (String[] args) {
>     	try {    		
>     		Character.codePointAt(null, 6, 4);
>     		System.err.println("failed 1");
>     	} catch (IndexOutOfBoundsException e) {
>     		System.err.println("passed 1");
>             e.printStackTrace();
>     	} catch (Exception e) {
>     		System.err.println("failed 1");
>             e.printStackTrace();
>     	}
>     	try {    		
>     		Character.codePointAt(null, 4, 6);
>     		System.err.println("failed 2");
>     	} catch (NullPointerException e) {
>     		System.err.println("passed 2");
>             e.printStackTrace();
>     	} catch (Exception e) {
>     		System.err.println("failed 2");
>             e.printStackTrace();
>     	}
>     	try {    		
>     		Character.codePointAt(null, 0, 0);
>     		System.err.println("failed 3");
>     	} catch (IndexOutOfBoundsException e) {
>     		System.err.println("passed 3");
>             e.printStackTrace();
>     	} catch (Exception e) {
>     		System.err.println("failed 3");
>             e.printStackTrace();
>     	}
>   }   
>     
> }
> Output
> RI --------------------------------------------------------------------
> passed 1
> java.lang.IndexOutOfBoundsException
> 	at java.lang.Character.codePointAt(Character.java:2400)
> 	at bug9276.main(bug9276.java:6)
> passed 2
> java.lang.NullPointerException
> 	at java.lang.Character.codePointAt(Character.java:2399)
> 	at bug9276.main(bug9276.java:16)
> passed 3
> java.lang.IndexOutOfBoundsException
> 	at java.lang.Character.codePointAt(Character.java:2400)
> 	at bug9276.main(bug9276.java:26)
> Harmony -----------------------------------------------------------
> failed 1
> java.lang.NullPointerException
> 	at java.lang.Character.codePointAt(Character.java:1918)
> 	at bug9276.main(bug9276.java:6)
> passed 2
> java.lang.NullPointerException
> 	at java.lang.Character.codePointAt(Character.java:1918)
> 	at bug9276.main(bug9276.java:16)
> failed 3
> java.lang.NullPointerException
> 	at java.lang.Character.codePointAt(Character.java:1918)
> 	at bug9276.main(bug9276.java:26)

-- 
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] Commented: (HARMONY-1033) [classlib][lang]compatibility: expected IndexOutOfBoundsException for Character.codePointAt

Posted by Nathan Beyer <nb...@kc.rr.com>.
This patch seems fine. My concern is that the original patch would make the
code unreadable and confusing. Post a new patch file to the JIRA issue and
I'll apply it. Thanks.

-Nathan

> -----Original Message-----
> From: Denis Kishenko [mailto:dkishenko@gmail.com]
> Sent: Wednesday, August 02, 2006 3:31 AM
> To: harmony-dev@incubator.apache.org
> Subject: Re: [jira] Commented: (HARMONY-1033)
> [classlib][lang]compatibility: expected IndexOutOfBoundsException for
> Character.codePointAt
> 
> 2006/8/2, Andrew Zhang <zh...@gmail.com>:
> > Does following exception check code work?
> >
> >        if (index < 0 || index >= limit || limit < 0 || limit >
> seq.length)
> > {
> >            throw new IndexOutOfBoundsException();
> >        }
> >
> > The above code also throws NullPointerException if seq is null, and the
> > order of exception seems the same as the patch.
> >
> > Does it make sense? Please correct me if I miss something. :)
> Yep, it's absolutely correct and looks better =)
> 
> Nathan as far as I understand you mean Harmony exception behavior is
> more logically than RI. Should we continue discussion or you will
> approve Alex's implementation?
> 
> ---------------------------------------------------------------------
> 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


---------------------------------------------------------------------
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] Commented: (HARMONY-1033) [classlib][lang]compatibility: expected IndexOutOfBoundsException for Character.codePointAt

Posted by Denis Kishenko <dk...@gmail.com>.
2006/8/2, Andrew Zhang <zh...@gmail.com>:
> Does following exception check code work?
>
>        if (index < 0 || index >= limit || limit < 0 || limit > seq.length)
> {
>            throw new IndexOutOfBoundsException();
>        }
>
> The above code also throws NullPointerException if seq is null, and the
> order of exception seems the same as the patch.
>
> Does it make sense? Please correct me if I miss something. :)
Yep, it's absolutely correct and looks better =)

Nathan as far as I understand you mean Harmony exception behavior is
more logically than RI. Should we continue discussion or you will
approve Alex's implementation?

---------------------------------------------------------------------
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] Commented: (HARMONY-1033) [classlib][lang]compatibility: expected IndexOutOfBoundsException for Character.codePointAt

Posted by Andrew Zhang <zh...@gmail.com>.
Hi,

Does following exception check code work?

        if (index < 0 || index >= limit || limit < 0 || limit > seq.length)
{
            throw new IndexOutOfBoundsException();
        }

The above code also throws NullPointerException if seq is null, and the
order of exception seems the same as the patch.

Does it make sense? Please correct me if I miss something. :)

Thanks!


On 8/2/06, Denis Kishenko <dk...@gmail.com> wrote:
>
> Hi all
>
> We have strange exceptions behavior of RI implementation of
> Character.codePointAt.method.
>
> Spec 1.5 says
> public static int codePointAt(char[] a, int index, int limit)
> Throws:
>   NullPointerException - if a is null.
>   IndexOutOfBoundsException - if the index argument is negative or
> not less than the limit argument, or if the limit argument is negative
> or greater than the length of the char array.
>
> Practicallty we have
>
> RI
> Character.codePointAt(null, 6, 4) - IndexOutOfBoundsException
> Character.codePointAt(null, 4, 6) - NPE
> Character.codePointAt(null, 0, 0) - IndexOutOfBoundsException
>
> Harmony
> Character.codePointAt(null, 6, 4) - NPE
> Character.codePointAt(null, 4, 6) - NPE
> Character.codePointAt(null, 0, 0) - NPE
>
> Should we follow RI to repeat behavior of exceptions?
>
> 2006/8/2, Nathan Beyer (JIRA) <ji...@apache.org>:
> >    [
> http://issues.apache.org/jira/browse/HARMONY-1033?page=comments#action_12425114]
> >
> > Nathan Beyer commented on HARMONY-1033:
> > ---------------------------------------
> >
> > This seems like an extreme edge case. The code implements the
> specification and Harmony's results aren't surprising. I suggest bringing
> this up on the mailing list for additional feedback, as I'm not inclined to
> move forward with this change. The resulting code seems very awkward.
> >
> > > [classlib][lang]compatibility: expected IndexOutOfBoundsException
> for  Character.codePointAt
> > >
> --------------------------------------------------------------------------------------------
> > >
> > >                 Key: HARMONY-1033
> > >                 URL: http://issues.apache.org/jira/browse/HARMONY-1033
> > >             Project: Harmony
> > >          Issue Type: Bug
> > >          Components: Classlib
> > >            Reporter: Denis Kishenko
> > >         Assigned To: Nathan Beyer
> > >         Attachments: Character.patch, CharacterTest.patch
> > >
> > >
> > > Specs 1.5
> > > Methods throws
> > >   NullPointerException - if a is null.
> > >   IndexOutOfBoundsException - if offset or count is negative, or if
> offset + count is larger than the length of the given array.
> > > If first argument is null RI throws NPE only in the second test, it's
> strange, but we have to follow.
> > > public class bug9276 {
> > >     public static void main (String[] args) {
> > >       try {
> > >               Character.codePointAt(null, 6, 4);
> > >               System.err.println("failed 1");
> > >       } catch (IndexOutOfBoundsException e) {
> > >               System.err.println("passed 1");
> > >             e.printStackTrace();
> > >       } catch (Exception e) {
> > >               System.err.println("failed 1");
> > >             e.printStackTrace();
> > >       }
> > >       try {
> > >               Character.codePointAt(null, 4, 6);
> > >               System.err.println("failed 2");
> > >       } catch (NullPointerException e) {
> > >               System.err.println("passed 2");
> > >             e.printStackTrace();
> > >       } catch (Exception e) {
> > >               System.err.println("failed 2");
> > >             e.printStackTrace();
> > >       }
> > >       try {
> > >               Character.codePointAt(null, 0, 0);
> > >               System.err.println("failed 3");
> > >       } catch (IndexOutOfBoundsException e) {
> > >               System.err.println("passed 3");
> > >             e.printStackTrace();
> > >       } catch (Exception e) {
> > >               System.err.println("failed 3");
> > >             e.printStackTrace();
> > >       }
> > >   }
> > >
> > > }
> > > Output
> > > RI
> --------------------------------------------------------------------
> > > passed 1
> > > java.lang.IndexOutOfBoundsException
> > >       at java.lang.Character.codePointAt(Character.java:2400)
> > >       at bug9276.main(bug9276.java:6)
> > > passed 2
> > > java.lang.NullPointerException
> > >       at java.lang.Character.codePointAt(Character.java:2399)
> > >       at bug9276.main(bug9276.java:16)
> > > passed 3
> > > java.lang.IndexOutOfBoundsException
> > >       at java.lang.Character.codePointAt(Character.java:2400)
> > >       at bug9276.main(bug9276.java:26)
> > > Harmony -----------------------------------------------------------
> > > failed 1
> > > java.lang.NullPointerException
> > >       at java.lang.Character.codePointAt(Character.java:1918)
> > >       at bug9276.main(bug9276.java:6)
> > > passed 2
> > > java.lang.NullPointerException
> > >       at java.lang.Character.codePointAt(Character.java:1918)
> > >       at bug9276.main(bug9276.java:16)
> > > failed 3
> > > java.lang.NullPointerException
> > >       at java.lang.Character.codePointAt(Character.java:1918)
> > >       at bug9276.main(bug9276.java:26)
> >
> > --
> > 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
> >
> >
> >
>
>
> --
> Denis M. Kishenko
> 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
>
>


-- 
Andrew Zhang
China Software Development Lab, IBM

Re: [jira] Commented: (HARMONY-1033) [classlib][lang]compatibility: expected IndexOutOfBoundsException for Character.codePointAt

Posted by Denis Kishenko <dk...@gmail.com>.
Hi all

We have strange exceptions behavior of RI implementation of
Character.codePointAt.method.

Spec 1.5 says
public static int codePointAt(char[] a, int index, int limit)
Throws:
   NullPointerException - if a is null.
   IndexOutOfBoundsException - if the index argument is negative or
not less than the limit argument, or if the limit argument is negative
or greater than the length of the char array.

Practicallty we have

RI
Character.codePointAt(null, 6, 4) - IndexOutOfBoundsException
Character.codePointAt(null, 4, 6) - NPE
Character.codePointAt(null, 0, 0) - IndexOutOfBoundsException

Harmony
Character.codePointAt(null, 6, 4) - NPE
Character.codePointAt(null, 4, 6) - NPE
Character.codePointAt(null, 0, 0) - NPE

Should we follow RI to repeat behavior of exceptions?

2006/8/2, Nathan Beyer (JIRA) <ji...@apache.org>:
>    [ http://issues.apache.org/jira/browse/HARMONY-1033?page=comments#action_12425114 ]
>
> Nathan Beyer commented on HARMONY-1033:
> ---------------------------------------
>
> This seems like an extreme edge case. The code implements the specification and Harmony's results aren't surprising. I suggest bringing this up on the mailing list for additional feedback, as I'm not inclined to move forward with this change. The resulting code seems very awkward.
>
> > [classlib][lang]compatibility: expected IndexOutOfBoundsException for  Character.codePointAt
> > --------------------------------------------------------------------------------------------
> >
> >                 Key: HARMONY-1033
> >                 URL: http://issues.apache.org/jira/browse/HARMONY-1033
> >             Project: Harmony
> >          Issue Type: Bug
> >          Components: Classlib
> >            Reporter: Denis Kishenko
> >         Assigned To: Nathan Beyer
> >         Attachments: Character.patch, CharacterTest.patch
> >
> >
> > Specs 1.5
> > Methods throws
> >   NullPointerException - if a is null.
> >   IndexOutOfBoundsException - if offset or count is negative, or if offset + count is larger than the length of the given array.
> > If first argument is null RI throws NPE only in the second test, it's strange, but we have to follow.
> > public class bug9276 {
> >     public static void main (String[] args) {
> >       try {
> >               Character.codePointAt(null, 6, 4);
> >               System.err.println("failed 1");
> >       } catch (IndexOutOfBoundsException e) {
> >               System.err.println("passed 1");
> >             e.printStackTrace();
> >       } catch (Exception e) {
> >               System.err.println("failed 1");
> >             e.printStackTrace();
> >       }
> >       try {
> >               Character.codePointAt(null, 4, 6);
> >               System.err.println("failed 2");
> >       } catch (NullPointerException e) {
> >               System.err.println("passed 2");
> >             e.printStackTrace();
> >       } catch (Exception e) {
> >               System.err.println("failed 2");
> >             e.printStackTrace();
> >       }
> >       try {
> >               Character.codePointAt(null, 0, 0);
> >               System.err.println("failed 3");
> >       } catch (IndexOutOfBoundsException e) {
> >               System.err.println("passed 3");
> >             e.printStackTrace();
> >       } catch (Exception e) {
> >               System.err.println("failed 3");
> >             e.printStackTrace();
> >       }
> >   }
> >
> > }
> > Output
> > RI --------------------------------------------------------------------
> > passed 1
> > java.lang.IndexOutOfBoundsException
> >       at java.lang.Character.codePointAt(Character.java:2400)
> >       at bug9276.main(bug9276.java:6)
> > passed 2
> > java.lang.NullPointerException
> >       at java.lang.Character.codePointAt(Character.java:2399)
> >       at bug9276.main(bug9276.java:16)
> > passed 3
> > java.lang.IndexOutOfBoundsException
> >       at java.lang.Character.codePointAt(Character.java:2400)
> >       at bug9276.main(bug9276.java:26)
> > Harmony -----------------------------------------------------------
> > failed 1
> > java.lang.NullPointerException
> >       at java.lang.Character.codePointAt(Character.java:1918)
> >       at bug9276.main(bug9276.java:6)
> > passed 2
> > java.lang.NullPointerException
> >       at java.lang.Character.codePointAt(Character.java:1918)
> >       at bug9276.main(bug9276.java:16)
> > failed 3
> > java.lang.NullPointerException
> >       at java.lang.Character.codePointAt(Character.java:1918)
> >       at bug9276.main(bug9276.java:26)
>
> --
> 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
>
>
>


-- 
Denis M. Kishenko
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