Index: vm/vmcore/src/jvmti/jvmti_thread.cpp =================================================================== --- vm/vmcore/src/jvmti/jvmti_thread.cpp (revision 579929) +++ vm/vmcore/src/jvmti/jvmti_thread.cpp (working copy) @@ -499,34 +499,37 @@ if (info_ptr == NULL) return JVMTI_ERROR_NULL_POINTER; - if (NULL != thread) - { - if (!is_valid_thread_object(thread)) + if (NULL != thread) { + if (!is_valid_thread_object(thread)) { return JVMTI_ERROR_INVALID_THREAD; - } - else + } + } else { thread = jthread_self(); + assert(thread != NULL); + } - ti->setLocallyDisabled();//-----------------------------------V - jclass cl = GetObjectClass(jvmti_test_jenv, thread); - jmethodID id = jvmti_test_jenv -> GetMethodID(cl, "getName","()Ljava/lang/String;"); - jstring name = jvmti_test_jenv -> CallObjectMethod (thread, id); - info_ptr -> name = (char *)jvmti_test_jenv -> GetStringUTFChars (name, false); - id = jvmti_test_jenv -> GetMethodID(cl, "getPriority","()I"); - info_ptr -> priority = jvmti_test_jenv -> CallIntMethod (thread, id); + jfieldID id = jvmti_test_jenv->GetFieldID(cl, "name", "Ljava/lang/String;"); + assert(id != NULL); // field must exist in kernel class + jstring name = jvmti_test_jenv->GetObjectField(thread, id); + info_ptr->name = (char*)jvmti_test_jenv->GetStringUTFChars(name, false); - id = jvmti_test_jenv -> GetMethodID(cl, "isDaemon","()Z"); - info_ptr -> is_daemon = jvmti_test_jenv -> CallBooleanMethod (thread, id); + id = jvmti_test_jenv->GetFieldID(cl, "priority", "I"); + assert(id != NULL); // field must exist in kernel class + info_ptr->priority = jvmti_test_jenv->GetIntField(thread, id); - id = jvmti_test_jenv -> GetMethodID(cl, "getThreadGroup","()Ljava/lang/ThreadGroup;"); - info_ptr -> thread_group = jvmti_test_jenv -> CallObjectMethod (thread, id); + id = jvmti_test_jenv->GetFieldID(cl, "daemon","Z"); + assert(id != NULL); // field must exist in kernel class + info_ptr->is_daemon = jvmti_test_jenv->GetBooleanField(thread, id); - id = jvmti_test_jenv -> GetMethodID(cl, "getContextClassLoader","()Ljava/lang/ClassLoader;"); - info_ptr -> context_class_loader = jvmti_test_jenv -> CallObjectMethod (thread, id); + id = jvmti_test_jenv->GetFieldID(cl, "group","Ljava/lang/ThreadGroup;"); + assert(id != NULL); // field must exist in kernel class + info_ptr->thread_group = jvmti_test_jenv->GetObjectField(thread, id); - ti->setLocallyEnabled();//------------------------------------^ + id = jvmti_test_jenv->GetFieldID(cl, "contextClassLoader","Ljava/lang/ClassLoader;"); + assert(id != NULL); // field must exist in kernel class + info_ptr->context_class_loader = jvmti_test_jenv->GetObjectField(thread, id); return JVMTI_ERROR_NONE; } @@ -682,14 +685,12 @@ return JVMTI_ERROR_NULL_POINTER; } - ti->setLocallyDisabled();//-----------------------------------V - // Set daemon flag for the thread jclass thread_class = GetObjectClass(jvmti_test_jenv, thread); assert(thread_class); - jmethodID set_daemon = GetMethodID(jvmti_test_jenv, thread_class, "setDaemon", "(Z)V"); - assert(set_daemon); - CallVoidMethod(jvmti_test_jenv, thread, set_daemon, JNI_TRUE); + jfieldID is_daemon = jvmti_test_jenv->GetFieldID(thread_class, "daemon", "Z"); + assert(is_daemon); + jvmti_test_jenv->SetBooleanField(thread, is_daemon, JNI_TRUE); jni_env = jthread_get_JNI_env(jthread_self()); @@ -703,8 +704,6 @@ jthread_create_with_function(jni_env, thread, &attrs); - ti->setLocallyEnabled();//-----------------------------------^ - return JVMTI_ERROR_NONE; } Index: vm/vmcore/src/jvmti/jvmti_thread_group.cpp =================================================================== --- vm/vmcore/src/jvmti/jvmti_thread_group.cpp (revision 579929) +++ vm/vmcore/src/jvmti/jvmti_thread_group.cpp (working copy) @@ -61,26 +61,25 @@ return JVMTI_ERROR_NULL_POINTER; } - ti->setLocallyDisabled();//-----------------------------------V - jclass cl = struct_Class_to_java_lang_Class_Handle(VM_Global_State::loader_env->java_lang_Thread_Class); - jmethodID id = jvmti_test_jenv -> GetMethodID(cl, - "getThreadGroup","()Ljava/lang/ThreadGroup;"); - jobject current_thread = (jobject)jthread_self(); - jobject group = jvmti_test_jenv -> CallObjectMethod (current_thread, id); + jfieldID id = jvmti_test_jenv->GetFieldID(cl, "group","Ljava/lang/ThreadGroup;"); + assert(id != NULL); + jthread current_thread = jthread_self(); + jobject group = jvmti_test_jenv->GetObjectField(current_thread, id); cl = struct_Class_to_java_lang_Class_Handle(VM_Global_State::loader_env->java_lang_ThreadGroup_Class); - id = jvmti_test_jenv -> GetMethodID(cl, - "getParent","()Ljava/lang/ThreadGroup;"); + id = jvmti_test_jenv->GetFieldID(cl, "parent","Ljava/lang/ThreadGroup;"); + assert(id != NULL); - jobject parent = jvmti_test_jenv -> CallObjectMethod (group, id); - while (parent) - { - group = parent; - parent = jvmti_test_jenv -> CallObjectMethod (group, id); - } + for(jobject parent = group; parent != NULL; + group = parent, parent = jvmti_test_jenv->GetObjectField(group, id)) + {} // empty loop - ti->setLocallyEnabled();//-----------------------------------^ + //while(parent != NULL) + //{ + // group = parent; + // parent = jvmti_test_jenv->GetObjectField(group, id); + //} jvmtiError jvmti_error = _allocate(sizeof(jthreadGroup*), (unsigned char **)groups_ptr); @@ -123,29 +122,28 @@ return JVMTI_ERROR_INVALID_THREAD_GROUP; } - if (info_ptr == NULL) - { + if (info_ptr == NULL) { return JVMTI_ERROR_NULL_POINTER; } - ti->setLocallyDisabled();//-----------------------------------V - jclass cl = GetObjectClass(jvmti_test_jenv, group); - jmethodID id = jvmti_test_jenv -> GetMethodID(cl, "getParent","()Ljava/lang/ThreadGroup;"); - info_ptr -> parent = jvmti_test_jenv -> CallObjectMethod (group, id); + jfieldID id = jvmti_test_jenv->GetFieldID(cl, "parent","Ljava/lang/ThreadGroup;"); + assert(id != NULL); + info_ptr->parent = jvmti_test_jenv->GetObjectField(group, id); - id = jvmti_test_jenv -> GetMethodID(cl, "getName","()Ljava/lang/String;"); - jstring name = jvmti_test_jenv -> CallObjectMethod (group, id); - info_ptr -> name = (char *)jvmti_test_jenv -> GetStringUTFChars (name, false); + id = jvmti_test_jenv->GetFieldID(cl, "name","Ljava/lang/String;"); + assert(id != NULL); + jstring name = jvmti_test_jenv->GetObjectField(group, id); + info_ptr->name = (char*)jvmti_test_jenv->GetStringUTFChars(name, false); - id = jvmti_test_jenv -> GetMethodID(cl, "getMaxPriority","()I"); - info_ptr -> max_priority = jvmti_test_jenv -> CallIntMethod (group, id); + id = jvmti_test_jenv->GetFieldID(cl, "maxPriority","I"); + assert(id != NULL); + info_ptr->max_priority = jvmti_test_jenv->GetIntField(group, id); - id = jvmti_test_jenv -> GetMethodID(cl, "isDaemon","()Z"); - info_ptr -> is_daemon = jvmti_test_jenv -> CallBooleanMethod (group, id); + id = jvmti_test_jenv->GetFieldID(cl, "daemon","Z"); + assert(id != NULL); + info_ptr->is_daemon = jvmti_test_jenv->GetBooleanField(group, id); - ti->setLocallyEnabled();//-----------------------------------^ - return JVMTI_ERROR_NONE; } Index: vm/vmcore/src/jvmti/jvmti_break_intf.cpp =================================================================== --- vm/vmcore/src/jvmti/jvmti_break_intf.cpp (revision 579929) +++ vm/vmcore/src/jvmti/jvmti_break_intf.cpp (working copy) @@ -587,7 +587,12 @@ // inside of callbacks InstructionDisassembler idisasm(*bp->disasm); - for (unsigned priority = 0; priority < PRIORITY_NUMBER; priority++) + bool is_enabled = VM_Global_State::loader_env->TI->isLocallyEnabled(); + // if is_enabled is false then we should continue execution without + // reporting breakpoint event + for (unsigned priority = 0; + is_enabled && priority < PRIORITY_NUMBER; + priority++) { bp = find_breakpoint(addr); assert(!bp || bp->addr == addr); @@ -808,7 +813,12 @@ << " :" << location ); jbyte orig_byte = bp->saved_byte; - for (unsigned priority = 0; priority < PRIORITY_NUMBER; priority++) + bool is_enabled = VM_Global_State::loader_env->TI->isLocallyEnabled(); + // if is_enabled is false then we should continue execution without + // reporting breakpoint event + for (unsigned priority = 0; + is_enabled && priority < PRIORITY_NUMBER; + priority++) { bp = find_breakpoint(method, location);; assert(bp->method == method); @@ -1317,7 +1327,7 @@ TRACE2("jvmti.break", "BREAKPOINT occured: " << native_location); DebugUtilsTI *ti = VM_Global_State::loader_env->TI; - if (!ti->isEnabled() || ti->getPhase() != JVMTI_PHASE_LIVE) + if (ti->getPhase() != JVMTI_PHASE_LIVE) return false; // Now it is necessary to set up a transition to