On Tue, 3 Nov 2026 08:16:38 GMT, Jeremy Wood <[email protected]> wrote:
>> src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java line 74:
>>
>>> 72: private static CAccessible getCAccessible(final Accessible a, final
>>> boolean createIfUndefined) {
>>> 73: if (a == null) return null;
>>> 74: AccessibleContext context = a.getAccessibleContext();
>>
>> Suggestion:
>>
>> private static CAccessible getCAccessible(final Accessible a, final
>> boolean createIfUndefined, final boolean returnNullOnNullContext) {
>> if (a == null) return null;
>> AccessibleContext context = a.getAccessibleContext();
>> if (returnNullOnNullContext && context == null) return null;
>
> This looks structurally OK (I think the unit test will pass), but I don't
> think I understand the motivation behind it.
>
> Your proposed `returnNullOnNullContext ` parameter gives devs the choice: "in
> this edge case would you rather return null or throw a NPE?"
>
> That feels like a weird choice to offer. (Is there a precedent somewhere else
> in the codebase that works like this?)
>
> Thoughts?
This is a private implementation method that already has a `boolean` parameter
controlling another edge case.
> Is there a precedent somewhere else in the codebase that works like this?
Yes, in `java.lang.String` (the `exClass` parameter of the `encode*` methods
behaves like that):
https://github.com/openjdk/jdk/blob/002ea517c757bb48f729c469e5d6febbe8d861ef/src/java.base/share/classes/java/lang/String.java#L1090-L1096
https://github.com/openjdk/jdk/blob/002ea517c757bb48f729c469e5d6febbe8d861ef/src/java.base/share/classes/java/lang/String.java#L1454-L1460
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/33657#discussion_r4454240913