This PR fixes the leak in the mac system menu bar. Inside the native code, NewGlobalRef is called for the callable. Which makes it into a "GC-Root" until DeleteGlobalRef is called.
The DeleteGlobalRef is never called for the MenuEntry, if it's removed from the menu without removing it's callable. This PR adds logic, whether the Menu is inserted. If it's not inserted in a Menu anymore, then DeleteGlobalRef is called, by calling `_setCallback` with the callable "null". The unit test verifies, that this bug happened without this change, but no longer happens with this change. ------------- Commit messages: - JDK-8299423 - JDK-8299423 Changes: https://git.openjdk.org/jfx/pull/987/files Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=987&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8299423 Stats: 132 lines in 2 files changed: 130 ins; 0 del; 2 mod Patch: https://git.openjdk.org/jfx/pull/987.diff Fetch: git fetch https://git.openjdk.org/jfx pull/987/head:pull/987 PR: https://git.openjdk.org/jfx/pull/987