RFR: 8293862: javax/swing/JFileChooser/8046391/bug8046391.java failed with 'Cannot invoke "java.awt.Image.getWidth(java.awt.image.ImageObserver)" because "retVal" is null'
Alexey Ivanov
aivanov at openjdk.org
Thu Jan 11 11:45:37 UTC 2024
On Thu, 4 Jan 2024 12:32:21 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
> > Thank you, Karl, for bringing the problem in this PR. It already exist in JBS as [JDK-8320692](https://bugs.openjdk.org/browse/JDK-8320692): _Cannot invoke java.awt.Image.getWidth(java.awt.image.ImageObserver)_.
> > I added my observations there. The problem is likely applicable to other file types which have per-instance icons, however, these are uncommon with the exception of exe files. The suggested fix won't work, there should be an icon but we have to handle the fallback gracefully.
>
> @DevCharly Although the exception comes from the same code line, the root cause is different. In this PR, the problem was that a valid icon handle had been interpreted as invalid, thus a valid icon wasn't extracted. In case you reference, there's no icon to extract; I expect the shell to fallback to the default app icon automatically, but it doesn't happen, so we have to provide the fallback ourselves.
>
> It is a new case that hasn't been encountered before.
As [I commented in JBS](https://bugs.openjdk.org/browse/JDK-8320692?focusedId=14638065&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14638065), the `NullPointerException` isn't thrown for .exe files without icon in 21+6 where .exe files without icons are displayed with a generic Swing icon.
Yet NPE is thrown in 21+7 where this PR is integrated, this means the NPE you reported is a regression from this fix.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/12010#issuecomment-1886961298
More information about the client-libs-dev
mailing list