JDK-8289708 : Extract only the requested icon size
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 17,18,19,20
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: windows
  • Submitted: 2022-07-04
  • Updated: 2022-07-08
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 :  
Relates :  
Description
The current implementation of FileSystemView.getSystemIcon(java.io.File,int,int) returns a MultiResolutionImage if possible. Internally, it requests a predefined set of icons from Window [2][3].

Not all the sizes may be needed or used. Only the required size should be requested.

This point came up during code review for JDK-8282526 [4].

As pointed out in the discussion, implementing this could very tricky. The icon has to store file details to fetch the icon of the different size, which needs to be performed on the COM thread. The scale is not known until the icon is displayed.


[1] https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/javax/swing/filechooser/FileSystemView.html#getSystemIcon(java.io.File,int,int)
[2] https://github.com/openjdk/jdk/blob/7f52c50ba32eecf5f379f8db30ac6a5cc50b3b66/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java#L90
[3] https://github.com/openjdk/jdk/blob/7f52c50ba32eecf5f379f8db30ac6a5cc50b3b66/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java#L1144-L1148
[4] https://github.com/openjdk/jdk/pull/7805#discussion_r894171541
https://github.com/openjdk/jdk/pull/7805#discussion_r916952460