On Thu, 23 Jul 2026 06:43:01 GMT, Prasanta Sadhukhan <[email protected]> 
wrote:

> 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).

This pull request has now been integrated.

Changeset: 410a9522
Author:    Prasanta Sadhukhan <[email protected]>
URL:       
https://git.openjdk.org/jdk/commit/410a9522396d83dea09f8684b043e205d5b337fa
Stats:     30 lines in 1 file changed: 16 ins; 2 del; 12 mod

8388485: javax/swing/JInternalFrame/Test6505027.java fails with Cannot invoke 
"Object.getClass()" because "<local0>" is null

Reviewed-by: prr, serb

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

PR: https://git.openjdk.org/jdk/pull/32019

Reply via email to