Skip to content

Factor JAVA_HOME detection into one shared Makefile fragment - #896

Closed
mernst wants to merge 4 commits into
codespecs:masterfrom
mernst:java-home-fragment
Closed

mernst wants to merge 4 commits into
codespecs:masterfrom
mernst:java-home-fragment

Conversation

@mernst

@mernst mernst commented Oct 10, 2026

Copy link
Copy Markdown
Member

The JAVA_HOME detection block was copied into java/Makefile, tests/Makefile.common, and both junit Makefile.user files. This moves it to scripts/java-home.mak, which each of those files includes. It also uses ":=" (inside ifndef JAVA_HOME) so that the shell commands run once rather than on every expansion of JAVA_HOME.

This conflicts with #892 in the deleted lines; resolve by keeping the deletion.

Use ":=" so the shell commands run once, not on every expansion.
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 7 billable files and costs up to $1.75.

Or wait 34 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: codespecs/daikon/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 34b7e184-2ada-4350-a48a-149547a589b7

📥 Commits

Reviewing files that changed from the base of the PR and between 779e30d and f0dd11d.


📒 Files selected for processing (7)
  • Makefile
  • java/Makefile
  • scripts/daikon.bashrc
  • scripts/java-home.mak
  • tests/Makefile.common
  • tests/daikon-tests/junit/Makefile.user
  • tests/daikon-tests/junit5/Makefile.user

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

mernst and others added 3 commits October 10, 2026 12:33
Check that javac is on the PATH even when JAVA_HOME is set, report a
failure of /usr/libexec/java_home, warn when JAVA_HOME disagrees with the
javac on the PATH, compute JAVA_HOME with Make built-ins, and export it.
Include the fragment once in tests/Makefile.common, relative to that file
rather than DAIKONDIR, and after the Makefile.user includes.

Co-Authored-By: Claude <noreply@anthropic.com>
On macOS, use /usr/libexec/java_home only when the javac on the PATH is the
/usr/bin/javac stub; otherwise derive JAVA_HOME from the javac on the PATH.
Check that the derived JAVA_HOME contains bin/javac.  Make a mismatch between
JAVA_HOME and the javac on the PATH an error.  Do not export JAVA_HOME.
Simplify DAIKONDIR in tests/Makefile.common, and let Makefile.common add
JUNIT_CLASSPATH to JAVAC rather than redefining JAVAC in Makefile.user files.
- daikon.bashrc uses the same PATH-first JAVA_HOME logic as java-home.mak.
- java-home.mak recognizes a JDK by its release file, so a javac wrapper
  is neither used to infer JAVA_HOME nor checked against it.
- java-home.mak reports a nonexistent JAVA_HOME and paths with whitespace.
- The staging target sets JAVA_HOME only if /usr/lib/jvm/java-11 exists.
- JUnit tests use JUNIT_CLASSPATH even if JAVAC is set in the environment.
- tests/Makefile.common includes java-home.mak via DAIKONDIR.
mernst added a commit to mernst/daikon that referenced this pull request Oct 11, 2026
java/Makefile and tests/Makefile.common include java/java-home.mk, which
asks the JVM that runs javac for its home directory, so that a javac
wrapper script (as used by jenv, asdf, or mise) works.  If the user set
JAVA_HOME, it warns when the javac on the PATH is in a different JDK.
scripts/daikon.bashrc uses the same logic.

In the tests, the Java version check uses the JDK in JAVA_HOME and is
skipped when there is no JDK, so that targets such as "clean" work
without one.  JAVALIB_CLASSPATH contains only jar files that exist.

This incorporates the changes of codespecs#896.
@mernst

mernst commented Oct 11, 2026

Copy link
Copy Markdown
Member Author

Closing in favor of #897, which now incorporates this pull request's changes: one shared JAVA_HOME detection fragment (java/java-home.mk), a warning when JAVA_HOME disagrees with the javac on the PATH, the matching scripts/daikon.bashrc change, and the staging target fix.

@mernst mernst closed this Oct 11, 2026
@mernst
mernst deleted the java-home-fragment branch October 11, 2026 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant