Repository navigation
formula: skip Java splash screens in macOS tests - #24005
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused implementation matches OpenJDK launcher behaviour and includes appropriate platform-specific tests.
Pull request overview
Ensures Java JAR splash screens do not access unavailable macOS window services during sandboxed formula phases.
Changes:
- Adds launcher-level headless configuration on macOS.
- Adds macOS and Linux coverage for platform-specific behaviour.
File summaries
| File | Description |
|---|---|
Library/Homebrew/extend/os/mac/formula.rb |
Sets headless options for the JVM and Java launcher. |
Library/Homebrew/test/os/mac/formula_spec.rb |
Verifies the macOS launcher option. |
Library/Homebrew/test/os/linux/formula_spec.rb |
Verifies Linux remains unchanged. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Contributor
Author
|
@MikeMcQuaid can you review this PR? |
ashr123
marked this pull request as draft
September 16, 2026 20:03
- The `java` launcher decides from the options it parses itself, its arguments and `JDK_JAVA_OPTIONS`, whether to show a jar's `SplashScreen-Image`. `_JAVA_OPTIONS` is only read by the JVM, so the headless option from Homebrew#24001 cannot switch the splash off. - On macOS the splash brings up AppKit, which needs the WindowServer and a LaunchServices check-in, so under the sandbox's `(deny mach-lookup)` the process aborts: `brew test jpdfbookmarks` fails with the JVM exiting 134 and no Java error printed. - Add `Formula#test_sandbox_env` and set `JDK_JAVA_OPTIONS` there on macOS only. OpenJDK's `configure` refuses a boot JDK whose `-version` output reports picked-up options, and the JDK formulae clear only `_JAVA_OPTIONS` before building, so the build phase must stay as is. - Cover the shared, macOS and Linux behaviour in the `Formula` specs.
ashr123
force-pushed
the
java-launcher-splash-headless
branch
from
September 16, 2026 20:10
b9bf275 to
12ec3aa
Compare
ashr123
marked this pull request as ready for review
September 16, 2026 20:10
5 of 8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
brew benchmarkresults.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?AI disclosure: Claude Code (Claude Fable 5.1) diagnosed the failure, wrote the patch and the spec changes, and ran
brew lgtmand the reproduction below; I reviewed the diff and will handle review comments myself.Follow-up to #24000 / #24001.
What: adds
Formula#test_sandbox_env, the environment of the sandboxed test phase on top ofcommon_sandbox_env, and on macOS setsJDK_JAVA_OPTIONS=-Djava.awt.headless=truethere, next to the-Djava.awt.headless=truethat #24001 appended to_JAVA_OPTIONSfor every phase.Why: the
javalauncher decides whether to show a jar'sSplashScreen-Imagewhile parsing its own command line, before the JVM exists (java.c#L1356-L1364, #L1422-L1430). It honours only a-Djava.awt.headless=trueit parsed itself, from its arguments or fromJDK_JAVA_OPTIONS(JDK 9+);_JAVA_OPTIONSis read later by the JVM and cannot switch the splash off. On macOS the splash initialises AppKit (splashscreen_sys.m#L152-L155), which needs a WindowServer connection and a LaunchServices check-in, so under(deny mach-lookup)the process aborts before the application'smainruns; a class-load trace shows no AWT class loaded at that point.brew test jpdfbookmarks(its jar manifest hasSplashScreen-Image) is so far the only failure in Homebrew/homebrew-core#311429: it fails on all three macOS lanes in the dependents shard that runs it, with nothing printed after the JVM'sPicked up _JAVA_OPTIONS: …line, and it fails identically locally withopenjdk26.0.2.1, so it is unrelated to the JDK version.Why only the test phase: OpenJDK's
configureprobes the boot JDK withjava -version 2>&1and aborts with "Cannot continue" when that output contains "Picked up" (boot-jdk.m4#L79-L86). Theopenjdk,openjdk@11/17/21/25,graalvmandopenj9formulae clear only_JAVA_OPTIONSbefore configuring, so settingJDK_JAVA_OPTIONSincommon_sandbox_env(my first revision of this PR) would have broken every macOS source build of a JDK. The test phase never configures a JDK, and it is where the splash failure happens.Reproduction (macOS 26.5, Homebrew 7.0.3 with #24001,
openjdk26.0.2.1,jpdfbookmarks2.5.2):Standalone, same command as the formula test, under the exact profile
brew testgenerates (sandbox-exec -f profile.sb):_JAVA_OPTIONS=-Djava.awt.headless=true(current)JDK_JAVA_OPTIONS=-Djava.awt.headless=truejava -Djava.awt.headless=true -jar …mach-lookupallowed forcom.apple.windowserver.activeandcom.apple.coreservices.launchservicesdThe last row is the alternative I did not take: it would widen the sandbox for every process to work around something the launcher already knows how to switch off, whereas this keeps
(deny mach-lookup)untouched.Side effects: the launcher prints
NOTE: Picked up JDK_JAVA_OPTIONS: -Djava.awt.headless=trueto stderr during tests, the same way the JVM already printsPicked up _JAVA_OPTIONS: …. Embedded JVMs that bypass the launcher are unaffected. The JDK 8 launcher has noJDK_JAVA_OPTIONS, so a splash jar tested onopenjdk@8would still abort; none does in homebrew-core today.Tests:
test/formula_spec.rbassertscommon_sandbox_envhas no launcher option;test/os/mac/formula_spec.rbasserts the exactJDK_JAVA_OPTIONSvalue intest_sandbox_envand that it keeps the common environment;test/os/linux/formula_spec.rbasserts the key is absent on Linux.