<AWT Dev> RFR: 8264125: Specification of Taskbar::getIconImage doesn't mention that the returned image might not be equal to the Taskbar::setIconImage one. (eg on Mac OS)

Alexander Zvegintsev azvegint at openjdk.java.net
Sat May 8 21:07:06 UTC 2021

On Fri, 7 May 2021 19:57:02 GMT, Phil Race <prr at openjdk.org> wrote:

> Leaving aside specification. what does an app really want this to return ?
> Should we start from there ?

We are returning current dock icon image from system.

> Do we definitely not want to just hang on to whatever an application set so we can return it without modification ?
> What are the problems with that ?

It might be a good solution, but I see some difficulties here.
If we just save passed image instance, its content might be modified by user between `setIconImage()` and `getIconImage()` calls.

`setIconImage()` internally converts passed image, so it does not follow its changes.
Thus we will get a discrepancy between result from `getIconImage()` and actual dock icon image on macOS side.
(Probably we can mitigate this by modifying the javadoc with some vague wording though.)

Ideally we should make a copy of an icon passed to `setIconImage()` method to prevent modification of its content.
`setIconImage()`/`getIconImage()` works with too wide type `java.awt.Image`, and I am not aware of any reliable way to clone every possible subtype of it.


PR: https://git.openjdk.java.net/jdk/pull/3250

More information about the awt-dev mailing list