Some JavaThread::jvmti_thread_state()/JvmtiThreadState::state_for()
callers are written correctly:
src/share/vm/prims/jni.cpp: jni_ExceptionClear()
620 JvmtiThreadState *state = JavaThread::current()->jvmti_thread_state();
621 if (state != NULL && state->is_exception_detected()) {
622 state->set_exception_caught();
623 }
And some JavaThread::jvmti_thread_state()/JvmtiThreadState::state_for()
callers assume that NULL can never be returned:
src/share/vm/prims/jvmtiEnv.cpp: JvmtiEnv::SetThreadLocalStorage()
100 // otherwise, create the state
101 state = JvmtiThreadState::state_for(java_thread);
102 }
103 state->env_thread_state(this)->set_agent_thread_local_storage_data((void*)data);