On Fri, 12 Feb 2021 22:14:35 GMT, Daniel D. Daugherty <[email protected]> 
wrote:

>> 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...

So Thread::is_JavaThread_protected() should be "protected" then, not public.
yes, I was suggesting adding a default last parameter like
    JavaThread::get_thread_name(char* default = Thread::name());
and pass "<NOT_FILLED_IN\>" from JVMTI. Then JVMTI doesn't have to be a friend 
and have more visibility to the JavaThread class than it should have.

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

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

Reply via email to