RFR: 8293862: javax/swing/JFileChooser/8046391/bug8046391.java failed with 'Cannot invoke "java.awt.Image.getWidth(java.awt.image.ImageObserver)" because "retVal" is null' [v2]

Alexey Ivanov aivanov at openjdk.org
Mon Dec 19 14:16:50 UTC 2022


On Mon, 19 Dec 2022 13:29:46 GMT, Tejesh R <tr at openjdk.org> wrote:

> > You may still add `assert` statements into `MultiResolutionIconImage` constructors which ensures `resolutionVariants` contains no `null` values.
> 
> Will add assert statements in this `public MultiResolutionIconImage(int baseSize, Image image)` as null checks are handled in other constructor.

What do you mean?

There are no `null`-checks in the other constructor. Or do I miss anything?

It's just you don't call the other constructor any more if an icon fetched from the OS is `null`. (Perhaps, it's not the most effective way: if another icon size is extracted correctly, a non-null value could still be returned.)

The following statement


assert !resolutionVariants.containsValue(null) : "There are null icons in the variants map";


would still prevent a `MultiResolutionIconImage` from being created if any resolution variant contains `null`. The code above could change again and we may end up with the same problem again.

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

PR: https://git.openjdk.org/jdk/pull/11104



More information about the client-libs-dev mailing list