On Mon, 19 Jun 2023 08:56:04 GMT, Abhishek Kumar <abhis...@openjdk.org> wrote:
>> src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java >> line 1121: >> >>> 1119: @Override >>> 1120: public int getAccessibleChildrenCount(JComponent c) { >>> 1121: return 2; >> >> I think the logic here has to be equal to the logic in `getAccessibleChild >> `, otherwise `getAccessibleChildrenCount` returns 2 even when >> `getAccessibleChild(..., 1)` returns null. > > Can you please elaborate more or what logic can be added here? I mean `getAccessibleChild(..., 1)` can still return null (when both `if`s of `case 1` resolve to false). Let's consider the following code: public void doSmthWith(JComponent component, BasicComboBoxUI ui) { if (ui.getAccessibleChildrenCount(component) > 1) { // well, we have at least 2 components, so we can expect to get a valid object below final var ac = ui.getAccessibleChild(component, 1) .getAccessibleContext(); // <= possible NPE // ... } } I think we have to return 1 from `getAccessibleChildrenCount(...)` for the cases when `getAccessibleChild(..., 1)` returns `null` ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/14497#discussion_r1233996986