[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-openjfx-dev
Subject:    Re: eclipse warnings
From:       John Hendrikx <john.hendrikx () gmail ! com>
Date:       2023-12-05 11:02:49
Message-ID: 3fdea815-67bc-f1c9-abca-02a46a1b39fd () gmail ! com
[Download RAW message or body]

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@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
> > 
> > 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic