diff options
author | 2015-06-18 00:02:11 +0000 | |
---|---|---|
committer | 2015-06-18 00:02:12 +0000 | |
commit | f16474d08ed51a3ccfaa70360aefdf12ebc79da1 (patch) | |
tree | 0f73cb94559ad3eeec6b6bb863377f4cb7366af1 | |
parent | 5592c688070fa327f56036c4c67c790289db63d9 (diff) | |
parent | 05b7226787f1470ad93f6f632fed60f70bc8631e (diff) |
Merge "Fix some java_lang_Class related moving GC bugs"
-rw-r--r-- | runtime/native/java_lang_Class.cc | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/runtime/native/java_lang_Class.cc b/runtime/native/java_lang_Class.cc index 67dcc9c6af..a41aed6f29 100644 --- a/runtime/native/java_lang_Class.cc +++ b/runtime/native/java_lang_Class.cc @@ -282,11 +282,11 @@ static ALWAYS_INLINE inline bool MethodMatchesConstructor(ArtMethod* m, bool pub static jobjectArray Class_getDeclaredConstructorsInternal( JNIEnv* env, jobject javaThis, jboolean publicOnly) { ScopedFastNativeObjectAccess soa(env); - auto* klass = DecodeClass(soa, javaThis); - StackHandleScope<1> hs(soa.Self()); + StackHandleScope<2> hs(soa.Self()); + Handle<mirror::Class> h_klass = hs.NewHandle(DecodeClass(soa, javaThis)); size_t constructor_count = 0; // Two pass approach for speed. - for (auto& m : klass->GetDirectMethods(sizeof(void*))) { + for (auto& m : h_klass->GetDirectMethods(sizeof(void*))) { constructor_count += MethodMatchesConstructor(&m, publicOnly != JNI_FALSE) ? 1u : 0u; } auto h_constructors = hs.NewHandle(mirror::ObjectArray<mirror::Constructor>::Alloc( @@ -296,7 +296,7 @@ static jobjectArray Class_getDeclaredConstructorsInternal( return nullptr; } constructor_count = 0; - for (auto& m : klass->GetDirectMethods(sizeof(void*))) { + for (auto& m : h_klass->GetDirectMethods(sizeof(void*))) { if (MethodMatchesConstructor(&m, publicOnly != JNI_FALSE)) { auto* constructor = mirror::Constructor::CreateFromArtMethod(soa.Self(), &m); if (UNLIKELY(constructor == nullptr)) { @@ -319,16 +319,16 @@ static jobject Class_getDeclaredMethodInternal(JNIEnv* env, jobject javaThis, // were synthesized by the runtime. constexpr uint32_t kSkipModifiers = kAccMiranda | kAccSynthetic; ScopedFastNativeObjectAccess soa(env); - StackHandleScope<4> hs(soa.Self()); + StackHandleScope<3> hs(soa.Self()); auto h_method_name = hs.NewHandle(soa.Decode<mirror::String*>(name)); if (UNLIKELY(h_method_name.Get() == nullptr)) { ThrowNullPointerException("name == null"); return nullptr; } auto h_args = hs.NewHandle(soa.Decode<mirror::ObjectArray<mirror::Class>*>(args)); - auto* klass = DecodeClass(soa, javaThis); + Handle<mirror::Class> h_klass = hs.NewHandle(DecodeClass(soa, javaThis)); ArtMethod* result = nullptr; - for (auto& m : klass->GetVirtualMethods(sizeof(void*))) { + for (auto& m : h_klass->GetVirtualMethods(sizeof(void*))) { auto* np_method = m.GetInterfaceMethodIfProxy(sizeof(void*)); // May cause thread suspension. mirror::String* np_name = np_method->GetNameAsString(soa.Self()); @@ -347,7 +347,7 @@ static jobject Class_getDeclaredMethodInternal(JNIEnv* env, jobject javaThis, } } if (result == nullptr) { - for (auto& m : klass->GetDirectMethods(sizeof(void*))) { + for (auto& m : h_klass->GetDirectMethods(sizeof(void*))) { auto modifiers = m.GetAccessFlags(); if ((modifiers & kAccConstructor) != 0) { continue; @@ -381,7 +381,7 @@ static jobjectArray Class_getDeclaredMethodsUnchecked(JNIEnv* env, jobject javaT jboolean publicOnly) { ScopedFastNativeObjectAccess soa(env); StackHandleScope<2> hs(soa.Self()); - auto klass = hs.NewHandle(DecodeClass(soa, javaThis)); + Handle<mirror::Class> klass = hs.NewHandle(DecodeClass(soa, javaThis)); size_t num_methods = 0; for (auto& m : klass->GetVirtualMethods(sizeof(void*))) { auto modifiers = m.GetAccessFlags(); @@ -432,7 +432,7 @@ static jobjectArray Class_getDeclaredMethodsUnchecked(JNIEnv* env, jobject javaT static jobject Class_newInstance(JNIEnv* env, jobject javaThis) { ScopedFastNativeObjectAccess soa(env); StackHandleScope<4> hs(soa.Self()); - auto klass = hs.NewHandle(DecodeClass(soa, javaThis)); + Handle<mirror::Class> klass = hs.NewHandle(DecodeClass(soa, javaThis)); if (UNLIKELY(klass->GetPrimitiveType() != 0 || klass->IsInterface() || klass->IsArrayClass() || klass->IsAbstract())) { soa.Self()->ThrowNewExceptionF("Ljava/lang/InstantiationException;", |