----- Original Message ----- > OpenJDK throws StringIndexOutOfBoundsException and so should we. > > Signed-off-by: Pekka Enberg <penb...@kernel.org> > --- > ChangeLog | 6 ++++++ > java/lang/String.java | 4 ++++ > 2 files changed, 10 insertions(+), 0 deletions(-) > > diff --git a/ChangeLog b/ChangeLog > index 5a75061..053ae62 100644 > --- a/ChangeLog > +++ b/ChangeLog > @@ -1,5 +1,11 @@ > 2012-03-15 Pekka Enberg <penb...@kernel.org> > > + * java/lang/String.java: > + (codePointAt): Fix exception type. > + (codePointBefore): Fix exception type. > + > +2012-03-15 Pekka Enberg <penb...@kernel.org> > + > * java/util/Formatter.java: > (format): Fix NPE errors. > > diff --git a/java/lang/String.java b/java/lang/String.java > index 45c0daf..eb713ce 100644 > --- a/java/lang/String.java > +++ b/java/lang/String.java > @@ -705,6 +705,8 @@ public final class String > */ > public synchronized int codePointAt(int index) > { > + if (index < 0 || index >= count) > + throw new StringIndexOutOfBoundsException(index); > // Use the CharSequence overload as we get better range checking > // this way. > return Character.codePointAt(this, index); > @@ -722,6 +724,8 @@ public final class String > */ > public synchronized int codePointBefore(int index) > { > + if (index < 0 || index >= count) > + throw new StringIndexOutOfBoundsException(index); > // Use the CharSequence overload as we get better range checking > // this way. > return Character.codePointBefore(this, index); > -- > 1.7.7.6 > > >
The checks added to codePointBefore here are wrong and broke the OpenJDK build: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55140 The specification says: "IndexOutOfBoundsException - if the index argument is less than 1 or greater than the length of this string." whereas the code above has clearly just been copied from codePointAt. I'll commit a fix. -- Andrew :) Free Java Software Engineer Red Hat, Inc. (http://www.redhat.com) PGP Key: 248BDC07 (https://keys.indymedia.org/) Fingerprint = EC5A 1F5E C0AD 1D15 8F1F 8F91 3B96 A578 248B DC07