diff options
author | 2015-01-29 20:06:46 +0000 | |
---|---|---|
committer | 2015-02-12 11:54:37 +0000 | |
commit | a5afcfc73141e5e378d79a326d02c5c2039fb025 (patch) | |
tree | 424add9558fb816c4f1d2f4edd128f4f2a086d9a /runtime/mirror/string.h | |
parent | 5a3399deaf448c8434d9ba0916ff799b1b791d95 (diff) |
Be more lenient with 4 byte UTF-8 sequences.
Accept 4 byte sequences and convert them into surrogate
pairs instead of expecting 2 separate 3 byte sequences
each encoding one half of a surrogate pair.
Note that in addition to supporting 4 byte sequences in
strings from JNI, we also tolerate them in dex files. This
is mainly for consistency, and there's no need to claim any
sort of official support.
bug: 18848397
bug: https://code.google.com/p/android/issues/detail?id=81341
Change-Id: Ibc98d29e59d98803e640f2489ea4c56912a59b29
Diffstat (limited to 'runtime/mirror/string.h')
-rw-r--r-- | runtime/mirror/string.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/runtime/mirror/string.h b/runtime/mirror/string.h index 30b8aa3c97..6c22b9b6af 100644 --- a/runtime/mirror/string.h +++ b/runtime/mirror/string.h @@ -69,8 +69,6 @@ class MANAGED String FINAL : public Object { int32_t GetUtfLength() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - uint16_t CharAt(int32_t index) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - String* Intern() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static String* AllocFromUtf16(Thread* self, @@ -86,9 +84,14 @@ class MANAGED String FINAL : public Object { const char* utf8_data_in) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + // TODO: This is only used in the interpreter to compare against + // entries from a dex files constant pool (ArtField names). Should + // we unify this with Equals(const StringPiece&); ? bool Equals(const char* modified_utf8) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - // TODO: do we need this overload? give it a more intention-revealing name. + // TODO: This is only used to compare DexCache.location with + // a dex_file's location (which is an std::string). Do we really + // need this in mirror::String just for that one usage ? bool Equals(const StringPiece& modified_utf8) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -127,6 +130,9 @@ class MANAGED String FINAL : public Object { static void VisitRoots(RootCallback* callback, void* arg) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + // TODO: Make this private. It's only used on ObjectTest at the moment. + uint16_t UncheckedCharAt(int32_t index) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + private: void SetHashCode(int32_t new_hash_code) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Hash code is invariant so use non-transactional mode. Also disable check as we may run inside |