RFR: 8241403: JavaThread::get_thread_name() should be ThreadSMR-aware

Daniel D.Daugherty dcubed at openjdk.java.net
Fri Feb 12 22:17:41 UTC 2021


On Fri, 12 Feb 2021 22:02:18 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> A minor fix to add a new function:
>> 
>>     bool Thread::is_JavaThread_protected(const JavaThread* p)
>> 
>> that returns true when the target JavaThread* is protected and false
>> otherwise. Update JavaThread::get_thread_name() to create a
>> ThreadsListHandle and use the new is_JavaThread_protected(). Also
>> update JvmtiTrace::safe_get_thread_name() to use the new
>> is_JavaThread_protected().
>> 
>> This fix is tested via a Mach5 Tier[1-8] run.
>
> src/hotspot/share/runtime/thread.hpp line 1692:
> 
>> 1690:   const char* get_thread_name() const;
>> 1691:  protected:
>> 1692:   friend class JvmtiTrace;  // so get_thread_name_string() can be called
> 
> I was trying to think of a way to not have JvmtiTrace not be a friend of JavaThread for this, maybe by adding a default value parameter to return "<NOT FILLED IN\>" rather than Thread::name.
> is_JavaThread_protected only seems to be called by JvmtiTrace also, so should be private (with the friend, which also makes the friend unfortunate).

JavaThread::get_thread_name() also calls is_JavaThread_protected().

The "friend" is so that JvmtiTrace can call get_thread_name_string()
and we can get rid of the JvmtiTrace version of the logic. I kept the
"<NOT FILLED IN>" rather than figure out a way to call Thread::name()
so we don't introduce the possibility of a compatibility issue for any
code that might depend on that hand rolled string value...

-------------

PR: https://git.openjdk.java.net/jdk/pull/2535


More information about the serviceability-dev mailing list