On Thu, 25 Aug 2022 13:50:19 GMT, Nir Lisker <nlis...@openjdk.org> wrote:

>> It's definitely a hypothetical case. `getChildren()` is called all over the 
>> place in JavaFX without a null check, so I see no reason for null checks 
>> here.
>
> Technically correct, although the [doc of 
> `getChildren()`](https://openjfx.io/javadoc/18/javafx.graphics/javafx/scene/Parent.html#getChildren())
>  specifically says:
> 
>> Note to subclasses: if you override this method, you must return from your 
>> implementation the result of calling this super method. The actual list 
>> instance returned from any getChildren() implementation must be the list 
>> owned and managed by this Parent. The only typical purpose for overriding 
>> this method is to promote the method to be public.
> 
> So considering the case that an overriding method will return `null` is not 
> practical.
> 
> As for a `null` child, I think that that's also not allowed. Considering that 
> a child can be added at most once to a scenegraph, it would mean that only 1 
> `null` child is allowed. There might be more issues with `null` children. I 
> don't think there's a good reason to check for them.

Yep, right. While it is possible to override `getChildren()` and return null, 
it will break everywhere so we can also omit the null check here.

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

PR: https://git.openjdk.org/jfx/pull/841

Reply via email to