summaryrefslogtreecommitdiffstats
path: root/luni
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2010-04-10 12:01:10 -0700
committerElliott Hughes <enh@google.com>2010-04-10 12:01:10 -0700
commitd9d4093169787d2a52d0e392933f77ec08ff1045 (patch)
treeb8191591d792962c358176952b12ba1287c401b7 /luni
parent001171ea16e108f80a08b94c760d793ee1a2c943 (diff)
downloadlibcore-d9d4093169787d2a52d0e392933f77ec08ff1045.zip
libcore-d9d4093169787d2a52d0e392933f77ec08ff1045.tar.gz
libcore-d9d4093169787d2a52d0e392933f77ec08ff1045.tar.bz2
Throw the same exceptions as the RI from String methods.
String has its own StringIndexOutOfBoundsException subclass of IndexOutOfBoundsException. We can run more tests if we behave the same. The RI only admits to IndexOutOfBoundsException, though, so our documentation and throws clause shouldn't change. Change-Id: Ib87777f8a42d4bcac21e8f8f00f4dcbc0ada4201
Diffstat (limited to 'luni')
-rw-r--r--luni/src/main/java/java/lang/String.java11
1 files changed, 5 insertions, 6 deletions
diff --git a/luni/src/main/java/java/lang/String.java b/luni/src/main/java/java/lang/String.java
index 0e0381c..cb39e25 100644
--- a/luni/src/main/java/java/lang/String.java
+++ b/luni/src/main/java/java/lang/String.java
@@ -649,9 +649,8 @@ public final class String implements Serializable, Comparable<String>,
if (codePoints == null) {
throw new NullPointerException();
}
- if (offset < 0 || count < 0
- || (long) offset + (long) count > codePoints.length) {
- throw new IndexOutOfBoundsException();
+ if (offset < 0 || count < 0 || (long) offset + (long) count > codePoints.length) {
+ throw new StringIndexOutOfBoundsException();
}
this.offset = 0;
this.value = new char[count * 2];
@@ -2196,7 +2195,7 @@ public final class String implements Serializable, Comparable<String>,
*/
public int codePointAt(int index) {
if (index < 0 || index >= count) {
- throw new IndexOutOfBoundsException();
+ throw new StringIndexOutOfBoundsException();
}
int s = index + offset;
return Character.codePointAt(value, s, offset + count);
@@ -2217,7 +2216,7 @@ public final class String implements Serializable, Comparable<String>,
*/
public int codePointBefore(int index) {
if (index < 1 || index > count) {
- throw new IndexOutOfBoundsException();
+ throw new StringIndexOutOfBoundsException();
}
int s = index + offset;
return Character.codePointBefore(value, s);
@@ -2241,7 +2240,7 @@ public final class String implements Serializable, Comparable<String>,
*/
public int codePointCount(int beginIndex, int endIndex) {
if (beginIndex < 0 || endIndex > count || beginIndex > endIndex) {
- throw new IndexOutOfBoundsException();
+ throw new StringIndexOutOfBoundsException();
}
int s = beginIndex + offset;
return Character.codePointCount(value, s, endIndex - beginIndex);