eclipse warnings

John Hendrikx john.hendrikx at gmail.com
Tue Dec 5 11:02:49 UTC 2023


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

On 04/12/2023 18:39, Michael Strauß wrote:
> I also see lots of instances of a pattern where the the return value
> of a getter is checked, but then the getter is called again:
>
>      if (getScene() != null) {
>          getScene().getWindow() // and so on
>      }
>
> While this generally works, we can't be 100% sure that this isn't
> potentially defective code (there could be side effects that cause the
> returned value to be different). Do we care about fixing that?
>
>
>
> On Mon, Dec 4, 2023 at 5:34 PM Andy Goryachev <andy.goryachev at oracle.com> wrote:
>> Dear colleagues:
>>
>>
>>
>> Imported the openjfx project into another workspace with a more stringent error checking and discovered a few issues:
>>
>>
>>
>> potential null pointer access: 295
>> unnecessary cast or instanceof: 190
>> redundant null check: 61
>>
>>
>>
>> Do we want to clean these up?
>>
>>
>>
>> -andy
>>
>>


More information about the openjfx-dev mailing list