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

Alexey Ivanov aivanov at openjdk.java.net
Mon May 30 20:32:53 UTC 2022


On Mon, 30 May 2022 06:04:03 GMT, Tejesh R <duke at openjdk.java.net> 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:
> 
>   Removal of White space

Can't the test be automated?

Can you paint the table to a BufferredImage and catch the NPE?

test/jdk/javax/swing/JTableHeader/TableRendererTest.java line 2:

> 1: /*
> 2:  * Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.

Why is it 2002, 2022 if it's a new test?

You're taking the code from [JDK-6429812](https://bugs.openjdk.java.net/browse/JDK-6429812), it was created in 2006, so the first year can't be earlier than 2006.

test/jdk/javax/swing/JTableHeader/TableRendererTest.java line 50:

> 48:             = """
> 49:             INSTRUCTIONS:
> 50:              1. This is a Windows specific test. If you are not on Windows, press Pass.

Since it is a Windows-specific test, you have to add

 * @requires (os.family == "windows")

to the list of jtreg tags?

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

Changes requested by aivanov (Reviewer).

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



More information about the client-libs-dev mailing list