Skip to content

Replace OSXAdapter with java.awt.Desktop handlers - #557

Open
tonygermano wants to merge 2 commits into
OpenIntegrationEngine:mainfrom
tonygermano:client/drop-osxadapter
Open

tonygermano wants to merge 2 commits into
OpenIntegrationEngine:mainfrom
tonygermano:client/drop-osxadapter

Conversation

@tonygermano

Copy link
Copy Markdown
Member

Summary

OSXAdapter is Apple's sample adapter, under Apple's own license header (relates to #472), that installs the macOS About and Quit handlers by reflection against com.apple.eawt.Application. Its pre-Java-9 path implements com.apple.eawt.ApplicationListener, which JEP 272 removed; its Java 9+ path only works because the launcher passes --add-opens java.desktop/com.apple.eawt. Both end up at the same java.awt.desktop handlers that java.awt.Desktop has exposed publicly since Java 9, so the reflection, the add-opens, and the Apple-licensed file can all go. #544 drew attention to the class while converting its stderr prints.

  • Deletes OSXAdapter.java and registers the two handlers with java.awt.Desktop.setAboutHandler / setQuitHandler, guarded by isSupported instead of IS_OS_MAC. Linux and Windows report both actions unsupported, so nothing changes there. The quit handler keeps the old contract: Frame.logout(true) doesn't call System.exit, so it calls performQuit() when quitMac() returns true and cancelQuit() otherwise.
  • Simplifies BareBonesBrowserLaunch.openURL to call Desktop.browse directly and drops its com.apple.eio.FileManager and rundll32 fallbacks, which can't be reached on Java 17 since Desktop is always supported on macOS and Windows. The Unix browser search stays for Linux desktops without the GNOME libraries Desktop needs.
  • Removes the --add-opens for com.apple.eawt and com.apple.eio from server/mirth-client.jnlp, WebStartServletTest, and the devClient Gradle task. Nothing else referenced those packages.

Testing

I verified that the browser launching still works from non-GNOME linux.

This needs a manual check on macOS, which I can't do

  • The application menu's About item should open the About dialog
  • Cmd-Q while logged in should prompt for logout and exit only after it succeeds
  • Cmd-Q on the login window should exit.

That is the behavior the old Java 9+ path provided, so no change is expected.

Claude checked:

  • ./gradlew clean build: all 797 tests pass.
  • No remaining reference to com.apple anywhere in the repository.

🤖 Drafted with Claude Code

@tonygermano
tonygermano requested a review from a team November 3, 2026 20:21
@tonygermano tonygermano added the licensing Eclipse Intellectual Property (IP) due diligence: licensing, provenance, Dash results, IP reviews label Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Test Results

  141 files  ±0    141 suites  ±0   4m 13s ⏱️ +46s
  919 tests ±0    919 ✅ ±0  0 💤 ±0  0 ❌ ±0 
1 051 runs  ±0  1 045 ✅ ±0  6 💤 ±0  0 ❌ ±0 

Results for commit 3b73238. ± Comparison against base commit 991ed69.

♻️ This comment has been updated with latest results.

OSXAdapter is Apple's sample adapter, carried under Apple's own license
header, that installs the macOS About and Quit handlers by reflection
against com.apple.eawt.Application. Its pre-Java-9 path implements
com.apple.eawt.ApplicationListener, which JEP 272 removed, and its
Java 9+ path only works because the client launcher passes
--add-opens java.desktop/com.apple.eawt. Both reach the same
java.awt.desktop handlers that java.awt.Desktop has exposed publicly
since Java 9.

Register the two handlers through Desktop directly, guarded by
isSupported so the IS_OS_MAC check is no longer needed; Linux and
Windows report both actions unsupported and keep their Help menu and
window close behavior. The quit handler keeps the old contract:
Frame.logout(true) does not call System.exit, so it calls performQuit
when quitMac returns true and cancelQuit otherwise.

Delete OSXAdapter.java and drop the --add-opens for com.apple.eawt,
which existed only for it, from the JNLP template, its test, and the
devClient task.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Tony Germano <tony@germano.name>
openURL located java.awt.Desktop by reflection and, when that failed,
fell back to com.apple.eio.FileManager on macOS or rundll32 on Windows.
Java 17 is the baseline, so Desktop is always present, and on macOS and
Windows it is always supported on a desktop JVM, so neither branch
could be reached. Call Desktop.browse directly and keep only the Unix
browser search, which still matters on Linux desktops without the GNOME
libraries that Desktop needs. Drop the --add-opens for com.apple.eio
from the JNLP template, its test, and the devClient task.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Tony Germano <tony@germano.name>
@tonygermano
tonygermano force-pushed the client/drop-osxadapter branch from 38124c6 to 3b73238 Compare November 4, 2026 22:37
Comment on lines +49 to +55
String browser = null;
for (String b : browsers)
if (browser == null
&& Runtime.getRuntime().exec(new String[] { "which", b }).getInputStream().read() != -1)
Runtime.getRuntime().exec(new String[] { browser = b, url });
if (browser == null)
throw new Exception(Arrays.toString(browsers));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just go for the exec? This seems like it is a TOCTOU. Presumably the exec of the browser will fail sufficiently to avoid which - which is not required to be present as a binary in the first place - it's normally a shell built-in.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was preexisting code that came from the upsteam launcher. It's only showing up here because of a whitespace change.

It's iterating through an array of options, so we'd need to wrap it in a new try/catch to ignore all of the exceptions until it exhausts the list. I'm not sure what we would gain since this works in all Linux environments I've tested it in.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you review only commit 2 and hide whitespace changes, this change is just a delete and directly importing Desktop instead of finding it by reflection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

licensing Eclipse Intellectual Property (IP) due diligence: licensing, provenance, Dash results, IP reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants