On Fri, 23 Jan 2026 12:00:20 GMT, Prasanta Sadhukhan <[email protected]>
wrote:
>> Invoking `JPopupMenu.setInvoker(null)` causes NPE which is fixed in this PR
>
> Prasanta Sadhukhan has updated the pull request incrementally with one
> additional commit since the last revision:
>
> 8376169
Changes requested by aivanov (Reviewer).
src/java.desktop/share/classes/javax/swing/JPopupMenu.java line 957:
> 955: if (invoker != null) {
> 956: Component oldInvoker = this.invoker;
> 957: this.invoker = invoker;
This doesn't look right to me. Is `this.invoker == null` an invalid state?
I believe the only thing that requires to be guarded by `if (invoker != null)`
is `invoker.addPropertyChangeListener`; maybe `ui.installUI(this)`, however, I
can't see why the former should be skipped in cases where `invoker` is `null`.
test/jdk/javax/swing/JPopupMenu/TestPopupInvoker.java line 114:
> 112: if (frame != null) {
> 113: frame.dispose();
> 114: }
This shouldn't be done in the clean-up code because `popupMenu.setInvoker` may
throw NPE. You have to do it in the body of the test.
-------------
PR Review: https://git.openjdk.org/jdk/pull/29377#pullrequestreview-3697486686
PR Review Comment: https://git.openjdk.org/jdk/pull/29377#discussion_r2721215627
PR Review Comment: https://git.openjdk.org/jdk/pull/29377#discussion_r2721204197