diff options
author | Brian Carlstrom <bdc@google.com> | 2013-06-08 00:15:07 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2013-06-08 00:15:07 +0000 |
commit | f47f0bdff8807ff419fb3553e510abaa36a3f98b (patch) | |
tree | 44a9616f85957f29ed1e4c489528a4edcf3b4b60 /libdvm | |
parent | 30abb0bd592702a4b8c26ee18565c3c7625220c8 (diff) | |
parent | 3443a5e4e7ea9fa3fdc3495a1f2c44bea97ac100 (diff) | |
download | libcore-f47f0bdff8807ff419fb3553e510abaa36a3f98b.zip libcore-f47f0bdff8807ff419fb3553e510abaa36a3f98b.tar.gz libcore-f47f0bdff8807ff419fb3553e510abaa36a3f98b.tar.bz2 |
Merge "Offer default implementations of various dalvik intrinsics in the library."
Diffstat (limited to 'libdvm')
-rw-r--r-- | libdvm/src/main/java/java/lang/String.java | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/libdvm/src/main/java/java/lang/String.java b/libdvm/src/main/java/java/lang/String.java index 7f72154..27469f0 100644 --- a/libdvm/src/main/java/java/lang/String.java +++ b/libdvm/src/main/java/java/lang/String.java @@ -573,7 +573,12 @@ outer: * @throws IndexOutOfBoundsException * if {@code index < 0} or {@code index >= length()}. */ - public native char charAt(int index); + public char charAt(int index) { + if (index < 0 || index >= count) { + throw indexAndLength(index); + } + return value[offset + index]; + } private StringIndexOutOfBoundsException indexAndLength(int index) { throw new StringIndexOutOfBoundsException(this, index); @@ -1077,7 +1082,9 @@ outer: * * @since 1.6 */ - public native boolean isEmpty(); + public boolean isEmpty() { + return count == 0; + } /** * Returns the last index of the code point {@code c}, or -1. @@ -1197,11 +1204,11 @@ outer: } /** - * Returns the size of this string. - * - * @return the number of characters in this string. + * Returns the number of characters in this string. */ - public native int length(); + public int length() { + return count; + } /** * Compares the specified string to this string and compares the specified |