eclipse warnings

John Hendrikx john.hendrikx at gmail.com
Wed Dec 6 10:45:43 UTC 2023


Ah, that's a shame, it would have been useful ;-)

--John

On 06/12/2023 00:03, Scott Palmer wrote:
> I was about to say the same. I wish it did, and applied the rule that 
> null never matches.
>
> You could probably trick it with an ugly cast though.
>
> ((Object)getScene()) instanceof Scene s
> Maybe?
>
> Scott
>
>> On Dec 5, 2023, at 3:43 PM, Michael Strauß <michaelstrau2 at gmail.com> 
>> wrote:
>>
>> Unfortunately, this doesn't work. The Java language doesn't allow a
>> pattern to be the same type as the expression.
>>
>>
>> On Tue, Dec 5, 2023 at 1:27 PM John Hendrikx 
>> <john.hendrikx at gmail.com> wrote:
>>>
>>> When this runs on the FX thread it has to be safe, but it's not very 
>>> nice.
>>>
>>> These days you can do these kind of null chain checks like this:
>>>
>>>       if (getScene() instanceof Scene s && s.getWindow() instanceof
>>> Window w && w.isShowing()) {
>>>
>>>       }
>>>
>>> --John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20231206/4514d9e4/attachment.htm>


More information about the openjfx-dev mailing list