RFR: 8322239: [macos] a11y : java.lang.NullPointerException is thrown when focus is moved on the JTabbedPane [v4]

Alexey Ivanov aivanov at openjdk.org
Wed Feb 14 20:10:06 UTC 2024


On Wed, 14 Feb 2024 19:50:34 GMT, Alexander Zuev <kizune at openjdk.org> wrote:

>> Add null check for the Aqua LnF situation when tab is hidden die to the tabs overflow.
>
> Alexander Zuev has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Moved frame disposal to the EDT

test/jdk/javax/swing/JTabbedPane/TabbedPaneNPECheck.java line 90:

> 88:             if (accessible instanceof AccessibleComponent) {
> 89:                 try {
> 90:                     AccessibleComponent component = (AccessibleComponent) accessible;

You can you pattern matching if you like:
Suggestion:

            if (accessible instanceof AccessibleComponent component) {
                try {

test/jdk/javax/swing/JTabbedPane/TabbedPaneNPECheck.java line 93:

> 91:                     Point p = component.getLocationOnScreen();
> 92:                     Rectangle r = component.getBounds();
> 93:                 } catch (NullPointerException npe){

Suggestion:

                } catch (NullPointerException npe) {

Missing space.

test/jdk/javax/swing/JTabbedPane/TabbedPaneNPECheck.java line 95:

> 93:                 } catch (NullPointerException npe){
> 94:                     throw new RuntimeException("Unexpected NullPointerException " +
> 95:                             "while getting accessible component bounds: " + npe);

Suggestion:

                    throw new RuntimeException("Unexpected NullPointerException " +
                            "while getting accessible component bounds", npe);

Preserve the full context of NPE for analysing the failure if it ever occurs.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17736#discussion_r1490000244
PR Review Comment: https://git.openjdk.org/jdk/pull/17736#discussion_r1489997950
PR Review Comment: https://git.openjdk.org/jdk/pull/17736#discussion_r1489997555


More information about the client-libs-dev mailing list