Test fails with NPE citing java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "<local0>" is null at Test6505027.validate(Test6505027.java:108) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:583) at SwingTest.run(SwingTest.java:96) at SwingTest.start(SwingTest.java:131) at SwingTest.start(SwingTest.java:54) at Test6505027.main(Test6505027.java:67)
which can happen when the internal frame has not received native focus yet, or the Robot clickâs focus transfer has not completed. The test validates focus owner immediately after clicking cell (1,1). Robot `waitForIdle` and `delay `is added after cell click to give time before current focus owner check is called. Also, explicitly activated the internal frame after it has been added to the desktop pane: Also, `instanceof` check is used instead of `component.getClass().equals(JComboBox.class)` because it handles null cleanly and does not reject a valid subclass Additionally, `press()` and `validate() `was called in separate EDT and main thread respectively which can cause issues like this, so made sure they are called in same thread as SwingTest calls static methods in main thread. Recurrent CI test execution is found to be ok. --------- - [x] I confirm that I make this contribution in accordance with the [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). ------------- Commit messages: - 8388485: javax/swing/JInternalFrame/Test6505027.java fails with Cannot invoke Object.getClass() because <local0> is null Changes: https://git.openjdk.org/jdk/pull/32019/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=32019&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8388485 Stats: 29 lines in 1 file changed: 16 ins; 2 del; 11 mod Patch: https://git.openjdk.org/jdk/pull/32019.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/32019/head:pull/32019 PR: https://git.openjdk.org/jdk/pull/32019
