On Tue, 26 Dec 2023 10:24:42 GMT, Johan Vos <j...@openjdk.org> wrote:
> I'm still looking into adding a test. The challenge is that the (previously) > uncollected items are of type `com.sun.glass.ui.MenuItem`, and afaik we can't > use JMemoryBuddy to check the collectable state of instances on the heap that > we don't have a reference to ourselves. I see 2 options: > > * a unit test, with new shim classes so that we get access to > `com.sun.glass.ui.MenuItem` from the test. The problem here is that this > quickly becomes a test for the shim class and not for the real classes > * a systemtest that can somehow inspect the heap and count the instances of > `com.sun.glass.ui.MenuItem` Perhaps add a package private method to get access to `GlassSystemMenu#systemMenus` (or use reflection)? I think you could then put a weak reference on the returned list (or items) and see if that disappears. ------------- PR Comment: https://git.openjdk.org/jfx/pull/1283#issuecomment-1869617031