diff options
author | 2017-02-01 20:40:44 -0800 | |
---|---|---|
committer | 2017-02-02 10:53:14 -0800 | |
commit | ae78c2643375c7536affcec318a60d13d430f181 (patch) | |
tree | d7299730b4e84107d544f66b6a046af75f367669 /runtime/interpreter/unstarted_runtime.cc | |
parent | a85111c5f25310e3d0eac68a6f0d8cd7c6612dfe (diff) |
ART: Add UnstartedRuntime support for Class.getSimpleName
This requires two native methods, isAnonymousClass and
getDeclaringClass.
Add tests.
Bug: 34890992
Test: m
Test: m test-art-host
Test: Device boots
Change-Id: Ib3fca2a6bb6e367ef202ff864719cab979d6c793
Diffstat (limited to 'runtime/interpreter/unstarted_runtime.cc')
-rw-r--r-- | runtime/interpreter/unstarted_runtime.cc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/runtime/interpreter/unstarted_runtime.cc b/runtime/interpreter/unstarted_runtime.cc index feb6e0857a..371e2f1e65 100644 --- a/runtime/interpreter/unstarted_runtime.cc +++ b/runtime/interpreter/unstarted_runtime.cc @@ -401,6 +401,25 @@ void UnstartedRuntime::UnstartedClassGetDeclaredConstructor( result->SetL(constructor); } +void UnstartedRuntime::UnstartedClassGetDeclaringClass( + Thread* self, ShadowFrame* shadow_frame, JValue* result, size_t arg_offset) { + StackHandleScope<1> hs(self); + Handle<mirror::Class> klass(hs.NewHandle( + reinterpret_cast<mirror::Class*>(shadow_frame->GetVRegReference(arg_offset)))); + if (klass->IsProxyClass() || klass->GetDexCache() == nullptr) { + result->SetL(nullptr); + return; + } + // Return null for anonymous classes. + JValue is_anon_result; + UnstartedClassIsAnonymousClass(self, shadow_frame, &is_anon_result, arg_offset); + if (is_anon_result.GetZ() != 0) { + result->SetL(nullptr); + return; + } + result->SetL(annotations::GetDeclaringClass(klass)); +} + void UnstartedRuntime::UnstartedClassGetEnclosingClass( Thread* self, ShadowFrame* shadow_frame, JValue* result, size_t arg_offset) { StackHandleScope<1> hs(self); @@ -420,6 +439,23 @@ void UnstartedRuntime::UnstartedClassGetInnerClassFlags( result->SetI(mirror::Class::GetInnerClassFlags(klass, default_value)); } +void UnstartedRuntime::UnstartedClassIsAnonymousClass( + Thread* self, ShadowFrame* shadow_frame, JValue* result, size_t arg_offset) { + StackHandleScope<1> hs(self); + Handle<mirror::Class> klass(hs.NewHandle( + reinterpret_cast<mirror::Class*>(shadow_frame->GetVRegReference(arg_offset)))); + if (klass->IsProxyClass() || klass->GetDexCache() == nullptr) { + result->SetZ(false); + return; + } + mirror::String* class_name = nullptr; + if (!annotations::GetInnerClass(klass, &class_name)) { + result->SetZ(false); + return; + } + result->SetZ(class_name == nullptr); +} + static std::unique_ptr<MemMap> FindAndExtractEntry(const std::string& jar_file, const char* entry_name, size_t* size, |