On Mon, 19 Dec 2022 14:14:14 GMT, Alexey Ivanov <[email protected]> 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. > >> > 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. Means the other constructor is called in two places only and in those places null checks are done. So, even if we add assertion inside constructor, it will unreachable. ------------- PR: https://git.openjdk.org/jdk/pull/11104
