RFR: 6429812: NPE after calling JTable.updateUI() when using a header renderer + XP L&F [v5]

Sergey Bylokhov serb at openjdk.java.net
Thu Jun 2 22:33:39 UTC 2022


On Thu, 2 Jun 2022 12:25:18 GMT, Tejesh R <tr at openjdk.org> wrote:

>> _Header_ object not initialized/set when paint() method of `WindowTableHeaderUI` class is executed. The paint() event is executed through explicit call of `JTable.updateUI()` in the regression test. In order to set the _header_ to the _called_ JTable, it is set in the `getTableCellRendererComponent()` method, which in turn makes the _header_ object available during paint event without causing NPE.
>
> Tejesh R has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Changed from manual to Automatic Test

I see that the bug description has a test case which produce this exception. There are these lines on the stack:

	at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:116)
	at java.awt.Container.paint(Container.java:1978)
	at java.awt.Window.paint(Window.java:3906)

So your automatic test may override the paint method and catch an exception there. The main method will check some flags at the end. You can also repaint the window a few times to make sure it is painted. Can we iterate all installed L&F? It seems the test does not have any windows specific code.

I think that the rendering to the BufferedImage as suggested by @aivanov-jdk should work as well.

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

PR: https://git.openjdk.java.net/jdk/pull/8830



More information about the client-libs-dev mailing list