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