diff options
author | Elliott Hughes <enh@google.com> | 2011-07-07 13:47:33 -0700 |
---|---|---|
committer | Brian Carlstrom <bdc@google.com> | 2013-06-07 16:55:01 -0700 |
commit | 3443a5e4e7ea9fa3fdc3495a1f2c44bea97ac100 (patch) | |
tree | 797abb339748d4323c187d87b227a2d25caf3057 /libdvm/src | |
parent | 98ed9ca970a1b283bcfccbf3dbbd4d968458d452 (diff) | |
download | libcore-3443a5e4e7ea9fa3fdc3495a1f2c44bea97ac100.zip libcore-3443a5e4e7ea9fa3fdc3495a1f2c44bea97ac100.tar.gz libcore-3443a5e4e7ea9fa3fdc3495a1f2c44bea97ac100.tar.bz2 |
Offer default implementations of various dalvik intrinsics in the library.
(cherry-picked from commit 2f95766aac3df74c6c641232eec4791b2330c9df)
Change-Id: I1005ee22ed8a017bb536bfd76df2173c7e8dcf64
Diffstat (limited to 'libdvm/src')
-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 78776db..53560ad 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 |