Bug - Fixed OS X 10.15 + java 11.0.8+ Dock Icon no longer supported.

MCroft

Developer
Staff member
Disabled by Oracle due to a bug: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8230869

I put some print statements in the catch block that swallows all the errors in OSXAdapter, and got this, which is why I think that Oracle change is what broke it. I can make the badge show up on JRE 10 and lower and not on JRE 11, 13, or 15, with either the HotSpot or J9 JREs.

It's probably time to get rid of the try/catch for 10.4, which was replaced by 10.5 over 10 years back.

We could probably call the Taskbar.isSupported(Taskbar.Feature.ICON_BADGE_STRING) method instead of error trapping. It handles the 10.5 - 10.14 OS range as supported for badges, and we can skip it if we are on an OS that doesn't work, until they fix the issue...

I can't figure out how to do the introspection thing when I need an enumerated value from the method I'm calling, but I may get there eventually, unless one of y'all figures it out first or I get distracted by my shiny Laf project or something...

setDockIconBadge taskbar failure: java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at apple.dts.samplecode.osxadapter.OSXAdapter.setDockIconBadge(OSXAdapter.java:370)
at net.sourceforge.kolmafia.KoLCharacter.setAdventuresLeft(KoLCharacter.java:2593)
at net.sourceforge.kolmafia.request.CharPaneRequest.parseStatus(CharPaneRequest.java:1756)
at net.sourceforge.kolmafia.request.ApiRequest.parseStatus(ApiRequest.java:420)
at net.sourceforge.kolmafia.request.ApiRequest.parseStatus(ApiRequest.java:391)
at net.sourceforge.kolmafia.request.ApiRequest.parseResponse(ApiRequest.java:229)
at net.sourceforge.kolmafia.request.GenericRequest.processResponse(GenericRequest.java:2633)
at net.sourceforge.kolmafia.request.GenericRequest.retrieveServerReply(GenericRequest.java:2570)
at net.sourceforge.kolmafia.request.GenericRequest.retrieveServerReply(GenericRequest.java:2117)
at net.sourceforge.kolmafia.request.GenericRequest.externalExecute(GenericRequest.java:1675)
at net.sourceforge.kolmafia.request.GenericRequest.execute(GenericRequest.java:1658)
at net.sourceforge.kolmafia.request.GenericRequest.run(GenericRequest.java:1368)
at net.sourceforge.kolmafia.request.ApiRequest.run(ApiRequest.java:198)
at net.sourceforge.kolmafia.request.ApiRequest.updateStatus(ApiRequest.java:127)
at net.sourceforge.kolmafia.request.ApiRequest.updateStatus(ApiRequest.java:104)
at net.sourceforge.kolmafia.KoLmafia.refreshSession(KoLmafia.java:787)
at net.sourceforge.kolmafia.session.LoginManager.initialize(LoginManager.java:254)
at net.sourceforge.kolmafia.session.LoginManager.doLogin(LoginManager.java:137)
at net.sourceforge.kolmafia.session.LoginManager.login(LoginManager.java:82)
at net.sourceforge.kolmafia.request.LoginRequest.processLoginRequest(LoginRequest.java:409)
at net.sourceforge.kolmafia.request.GenericRequest.handleServerRedirect(GenericRequest.java:2251)
at net.sourceforge.kolmafia.request.GenericRequest.retrieveServerReply(GenericRequest.java:2127)
at net.sourceforge.kolmafia.request.GenericRequest.externalExecute(GenericRequest.java:1675)
at net.sourceforge.kolmafia.request.GenericRequest.execute(GenericRequest.java:1658)
at net.sourceforge.kolmafia.request.GenericRequest.run(GenericRequest.java:1368)
at net.sourceforge.kolmafia.request.LoginRequest.run(LoginRequest.java:270)
at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:300)
at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:250)
at net.sourceforge.kolmafia.KoLmafiaGUI.initialize(KoLmafiaGUI.java:113)
at net.sourceforge.kolmafia.KoLmafia.main(KoLmafia.java:390)
Caused by: java.lang.UnsupportedOperationException: The ICON_BADGE_NUMBER feature is not supported on the current platform!
at java.desktop/java.awt.Taskbar.checkFeatureSupport(Taskbar.java:175)
at java.desktop/java.awt.Taskbar.setIconBadge(Taskbar.java:373)
... 34 more
 
Last edited:

MCroft

Developer
Staff member
patch included

In java 9+, get Taskbar.isSupported() for the ICON_BADGE_TEXT feature and return immediately if it's false.

View attachment BadgeUpdageTestAndBypass.patch

Tested on MacOS Big Sur with JDK 8, 10, 15.
results: no badge on JDK 8, badge on JDK 10, no badge on JDK 15. I didn't do anything about 8, so that seems like it's an existing issue.

The advantage to this approach is that if the JDK suddenly fixes the property, the code just starts working.
 
Top