dorkbox / SystemTray

Cross-platform SystemTray support for Swing/AWT, macOS, GtkStatusIcon, and AppIndicator on Java 8+
Other
430 stars 58 forks source link

IllegalAccessError crash on macOS #207

Open Nohus opened 7 months ago

Nohus commented 7 months ago

System information: macOS 12.7.2 x86_64

Stack trace:

java.lang.IllegalAccessError: class java.awt.MenuComponentAccessory tried to access private field java.awt.TrayIcon.peer (java.awt.MenuComponentAccessory and java.awt.TrayIcon are in module java.desktop of loader 'bootstrap')
    at java.awt.MenuComponentAccessory.getLocation(MenuComponentAccessory.java)
    at dorkbox.systemTray.util.AwtAccessor.getLocation(AwtAccessor.java)
    at dorkbox.systemTray.ui.osx._OsxAwtTray$1$1.mouseClicked(_OsxAwtTray.java:174)
    at java.awt.TrayIcon.processMouseEvent(TrayIcon.java:771)
    at java.awt.TrayIcon.processEvent(TrayIcon.java:745)
    at java.awt.TrayIcon.dispatchEvent(TrayIcon.java:736)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:778)
    at java.awt.EventQueue$4.run(EventQueue.java:722)
    at java.awt.EventQueue$4.run(EventQueue.java:716)
    at java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
    at java.awt.EventQueue$5.run(EventQueue.java:746)
    at java.awt.EventQueue$5.run(EventQueue.java:744)
    at java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:743)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Logs:

image

Nohus commented 7 months ago

The solution seems to be to not try accessing peer if we failed to make it public previously.

dorkbox commented 7 months ago

I’ll look into that. Thanks!

dorkbox commented 7 months ago

Also, can you send me the java version, and how you’re running it?

Also with SystemTray.DEBUG = true ?

I develop and test this on MacOS (13 and 14), so it should work without issues, and I’m likely missing something for version 12.

Nohus commented 7 months ago

Here are the versions it happens on: image

I haven't managed to reproduce it myself, I only have crash reports from users. It doesn't look specific to MacOS 12.

dorkbox commented 7 months ago

Interesting. I will check this out with oracle’s runtime - they might have moved stuff around.

I tested just now with temurin and it’s working as expected