On Wed, 24 Jan 2024 20:25:26 GMT, Alexey Ivanov <[email protected]> wrote:

>> Prasanta Sadhukhan has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   Retain last component in rendererPane. Testcase added
>
> test/jdk/javax/swing/plaf/basic/BasicTreeUI/TreeCellRendererLeakTest.java 
> line 62:
> 
>> 60:         }
>> 61: 
>> 62:         public void finalize( ) {
> 
> The `finalize` method is deprecated. Can't we use `Reference` API for this 
> purpose?
> 
> Store a list of 
> [`PhantomReference<JLabel>`](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/ref/PhantomReference.html).
>  The size of the list is the number of `JLabel` objects created. Once you 
> receive a reference via the 
> [`ReferenceQueue`](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/ref/ReferenceQueue.html),
>  remove it from the list.

I was not sure of the nuances of PhantomReference and ReferenceQueue, so have 
used WeakReference logic in the test which I think is more simpler..

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17458#discussion_r1469118605

Reply via email to