On Wed, 4 Aug 2021 22:56:15 GMT, Serguei Spitsyn <[email protected]> wrote:
>> src/hotspot/share/jfr/utilities/jfrThreadIterator.hpp line 50:
>>
>>> 48: class JfrJavaThreadIteratorAdapter {
>>> 49: private:
>>> 50: ThreadsListHandle _tlist;
>>
>> Why do we need to store this?
>>
>> It looks very suspiocious to have a member that is a stackObj, in a class
>> that is not itself a stackObj. ??
>
> The _tlist is used locally in JfrJavaThreadIteratorAdapter constructor only,
> so it is possible to get rid of it for the price of complicating the
> constructor a little bit.
The `_tlist` is a handle that ensures the captured ThreadsList remains live
while the iterator (or a copy) exists. Dropping it would leave `_it` and
`_end` potentially dangling.
-------------
PR: https://git.openjdk.java.net/jdk/pull/4949