JDK-8289766 : Unify the two methods for extracting icons on Windows
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 17,18,19,20
  • Priority: P4
  • Status: New
  • Resolution: Unresolved
  • OS: windows
  • Submitted: 2022-07-05
  • Updated: 2022-07-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
There are two similar functions which extract icons on Windows: Java_sun_awt_shell_Win32ShellFolder2_getIcon [1][2] and Java_sun_awt_shell_Win32ShellFolder2_extractIcon [3][4].

The latter corresponds to the new method add in JDK-8182043: FileSystemView.getSystemIcon(File,int,int) [5]. The former is used internally by JFileChooser and by FileSystemView.getSystemIcon(File) [6].

The icons returned by Win32ShellFolder2.getIcon(boolean) are cached. There are some differences but basically both methods do the same thing.

It's worth looking whether it's possible to unify these two methods into one.


[1] https://github.com/openjdk/jdk/blob/7f52c50ba32eecf5f379f8db30ac6a5cc50b3b66/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java#L1052-L1129
[2] https://github.com/openjdk/jdk/blob/94127f43a4a28a89094fa93cd1da49763134f9db/src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp#L875-L888
[3] https://github.com/openjdk/jdk/blob/7f52c50ba32eecf5f379f8db30ac6a5cc50b3b66/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java#L1134-L1178
[4] https://github.com/openjdk/jdk/blob/94127f43a4a28a89094fa93cd1da49763134f9db/src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp#L960-L994
[5] https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/javax/swing/filechooser/FileSystemView.html#getSystemIcon(java.io.File,int,int)
[6] https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/javax/swing/filechooser/FileSystemView.html#getSystemIcon(java.io.File)