JDK-8286872 : Refactor add/modify notification icon (TrayIcon)
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7,19
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows
  • Submitted: 2022-05-17
  • Updated: 2022-11-15
  • Resolved: 2022-05-19
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.
JDK 11 JDK 17 JDK 19
11.0.18-oracleFixed 17.0.6-oracleFixed 19 b24Fixed
Related Reports
Relates :  
Description
AwtTrayIcon::WmTaskbarCreated [1] and AwtTrayIcon::_UpdateIcon [2] have duplicate code:

    BOOL result = trayIcon->SendTrayMessage(jupdate == JNI_TRUE ? NIM_MODIFY : NIM_ADD);
    // 6270114: Instructs the taskbar to behave according to the Shell version 5.0
    if (result && jupdate == JNI_FALSE) {
        trayIcon->SendTrayMessage(NIM_SETVERSION);
    }

The only difference is the usage of jupdate which controls whether the icon is to be added or modified.

These could be refactored into separate methods to avoid code duplication, especially in the case of adding where another method must be called.

[1] https://github.com/openjdk/jdk/blob/7b988b31c661c6e3e58cf8ced81732e40a79d4f5/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp#L477
[2] https://github.com/openjdk/jdk/blob/7b988b31c661c6e3e58cf8ced81732e40a79d4f5/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp#L796
Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jdk11u-dev/pull/1513 Date: 2022-11-11 10:21:15 +0000
11-11-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk17u-dev/pull/871 Date: 2022-11-10 11:10:59 +0000
10-11-2022

Fix request [17u] I backport this for parity with 17.0.6-oracle. Risk: follow up to 8255439 which we should take. Clean backport. Test of 8255439 passes. SAP nighlty testing passes (on win and others).
10-11-2022

Changeset: 9f562ef7 Author: Alexey Ivanov <aivanov@openjdk.org> Date: 2022-05-19 20:04:19 +0000 URL: https://git.openjdk.java.net/jdk/commit/9f562ef7546c80e6ddce7b932f3f5ca17c741d21
19-05-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/8749 Date: 2022-05-17 13:02:49 +0000
17-05-2022