summaryrefslogtreecommitdiff
path: root/openjdkjvmti/ti_threadgroup.cc
diff options
context:
space:
mode:
Diffstat (limited to 'openjdkjvmti/ti_threadgroup.cc')
-rw-r--r--openjdkjvmti/ti_threadgroup.cc43
1 files changed, 19 insertions, 24 deletions
diff --git a/openjdkjvmti/ti_threadgroup.cc b/openjdkjvmti/ti_threadgroup.cc
index bc912cf6a5..120024e8b2 100644
--- a/openjdkjvmti/ti_threadgroup.cc
+++ b/openjdkjvmti/ti_threadgroup.cc
@@ -47,7 +47,7 @@
#include "scoped_thread_state_change-inl.h"
#include "thread-current-inl.h"
#include "thread_list.h"
-#include "well_known_classes.h"
+#include "well_known_classes-inl.h"
namespace openjdkjvmti {
@@ -95,22 +95,21 @@ jvmtiError ThreadGroupUtil::GetThreadGroupInfo(jvmtiEnv* env,
}
art::ScopedObjectAccess soa(art::Thread::Current());
- if (soa.Env()->IsInstanceOf(group, art::WellKnownClasses::java_lang_ThreadGroup) == JNI_FALSE) {
+ art::StackHandleScope<2> hs(soa.Self());
+ art::Handle<art::mirror::Class> tg_class =
+ hs.NewHandle(art::WellKnownClasses::java_lang_ThreadGroup.Get());
+ art::Handle<art::mirror::Object> thread_group =
+ hs.NewHandle(soa.Decode<art::mirror::Object>(group));
+ if (!thread_group->InstanceOf(tg_class.Get())) {
return ERR(INVALID_THREAD_GROUP);
}
- art::StackHandleScope<2> hs(soa.Self());
- art::Handle<art::mirror::Class> tg_class(
- hs.NewHandle(soa.Decode<art::mirror::Class>(art::WellKnownClasses::java_lang_ThreadGroup)));
- art::Handle<art::mirror::Object> obj(hs.NewHandle(soa.Decode<art::mirror::Object>(group)));
-
// Do the name first. It's the only thing that can fail.
{
- art::ArtField* name_field =
- art::jni::DecodeArtField(art::WellKnownClasses::java_lang_ThreadGroup_name);
+ art::ArtField* name_field = art::WellKnownClasses::java_lang_ThreadGroup_name;
CHECK(name_field != nullptr);
art::ObjPtr<art::mirror::String> name_obj =
- art::ObjPtr<art::mirror::String>::DownCast(name_field->GetObject(obj.Get()));
+ art::ObjPtr<art::mirror::String>::DownCast(name_field->GetObject(thread_group.Get()));
std::string tmp_str;
const char* tmp_cstr;
if (name_obj == nullptr) {
@@ -129,10 +128,9 @@ jvmtiError ThreadGroupUtil::GetThreadGroupInfo(jvmtiEnv* env,
// Parent.
{
- art::ArtField* parent_field =
- art::jni::DecodeArtField(art::WellKnownClasses::java_lang_ThreadGroup_parent);
+ art::ArtField* parent_field = art::WellKnownClasses::java_lang_ThreadGroup_parent;
CHECK(parent_field != nullptr);
- art::ObjPtr<art::mirror::Object> parent_group = parent_field->GetObject(obj.Get());
+ art::ObjPtr<art::mirror::Object> parent_group = parent_field->GetObject(thread_group.Get());
info_ptr->parent = parent_group == nullptr
? nullptr
: soa.AddLocalReference<jthreadGroup>(parent_group);
@@ -142,14 +140,14 @@ jvmtiError ThreadGroupUtil::GetThreadGroupInfo(jvmtiEnv* env,
{
art::ArtField* prio_field = tg_class->FindDeclaredInstanceField("maxPriority", "I");
CHECK(prio_field != nullptr);
- info_ptr->max_priority = static_cast<jint>(prio_field->GetInt(obj.Get()));
+ info_ptr->max_priority = static_cast<jint>(prio_field->GetInt(thread_group.Get()));
}
// Daemon.
{
art::ArtField* daemon_field = tg_class->FindDeclaredInstanceField("daemon", "Z");
CHECK(daemon_field != nullptr);
- info_ptr->is_daemon = daemon_field->GetBoolean(obj.Get()) == 0 ? JNI_FALSE : JNI_TRUE;
+ info_ptr->is_daemon = daemon_field->GetBoolean(thread_group.Get()) == 0 ? JNI_FALSE : JNI_TRUE;
}
return ERR(NONE);
@@ -161,8 +159,7 @@ static bool IsInDesiredThreadGroup(art::Handle<art::mirror::Object> desired_thre
REQUIRES_SHARED(art::Locks::mutator_lock_) {
CHECK(desired_thread_group != nullptr);
- art::ArtField* thread_group_field =
- art::jni::DecodeArtField(art::WellKnownClasses::java_lang_Thread_group);
+ art::ArtField* thread_group_field = art::WellKnownClasses::java_lang_Thread_group;
DCHECK(thread_group_field != nullptr);
art::ObjPtr<art::mirror::Object> group = thread_group_field->GetObject(peer);
return (group == desired_thread_group.Get());
@@ -194,8 +191,7 @@ static void GetChildThreadGroups(art::Handle<art::mirror::Object> thread_group,
CHECK(thread_group != nullptr);
// Get the ThreadGroup[] "groups" out of this thread group...
- art::ArtField* groups_field =
- art::jni::DecodeArtField(art::WellKnownClasses::java_lang_ThreadGroup_groups);
+ art::ArtField* groups_field = art::WellKnownClasses::java_lang_ThreadGroup_groups;
art::ObjPtr<art::mirror::Object> groups_array = groups_field->GetObject(thread_group.Get());
if (groups_array == nullptr) {
@@ -225,14 +221,13 @@ jvmtiError ThreadGroupUtil::GetThreadGroupChildren(jvmtiEnv* env,
}
art::ScopedObjectAccess soa(art::Thread::Current());
-
- if (!soa.Env()->IsInstanceOf(group, art::WellKnownClasses::java_lang_ThreadGroup)) {
+ art::StackHandleScope<1> hs(soa.Self());
+ art::Handle<art::mirror::Object> thread_group =
+ hs.NewHandle(soa.Decode<art::mirror::Object>(group));
+ if (!thread_group->InstanceOf(art::WellKnownClasses::java_lang_ThreadGroup.Get())) {
return ERR(INVALID_THREAD_GROUP);
}
- art::StackHandleScope<1> hs(soa.Self());
- art::Handle<art::mirror::Object> thread_group = hs.NewHandle(
- soa.Decode<art::mirror::Object>(group));
art::ObjectLock<art::mirror::Object> thread_group_lock(soa.Self(), thread_group);