Skip to content

fix: detect JAVA_HOME with Java 11#1406

Merged
breautek merged 1 commit intoapache:masterfrom
ltm:fix-detect-java11
Mar 17, 2022
Merged

fix: detect JAVA_HOME with Java 11#1406
breautek merged 1 commit intoapache:masterfrom
ltm:fix-detect-java11

Conversation

@ltm
Copy link
Copy Markdown
Contributor

@ltm ltm commented Mar 11, 2022

Platforms affected

Linux and Windows

Motivation and Context

Starting with Java 9 the JRE and JDK no longer include tools.jar as described in JEP 220. As a result the check_java function is unable to detect a Java 11 installation unless the JAVA_HOME environment variable is set manually:

var maybeJavaHome = path.dirname(path.dirname(javacPath));
if (fs.existsSync(path.join(maybeJavaHome, 'lib', 'tools.jar'))) {

The check for tools.jar appears to have been added in commit 7133576.

Description

This change instead checks for the presence of ${maybeJavaHome}/bin/java or ${maybeJavaHome}/bin/java.exe. This is similar to the checks performed by gradlew and gradlew.bat.

Testing

On Debian 11:

$ readlink -f $(which javac)
/usr/lib/jvm/java-11-openjdk-amd64/bin/javac
$ ls /usr/lib/jvm/java-11-openjdk-amd64/lib/tools.jar
ls: cannot access '/usr/lib/jvm/java-11-openjdk-amd64/lib/tools.jar': No such file or directory
$ ls /usr/lib/jvm/java-11-openjdk-amd64/bin/java
/usr/lib/jvm/java-11-openjdk-amd64/bin/java

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 16, 2022

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.20%. Comparing base (6d3ce21) to head (c794ee5).
⚠️ Report is 190 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1406   +/-   ##
=======================================
  Coverage   73.20%   73.20%           
=======================================
  Files          21       21           
  Lines        1646     1646           
=======================================
  Hits         1205     1205           
  Misses        441      441           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@breautek breautek requested a review from erisu March 16, 2022 14:04
Copy link
Copy Markdown
Member

@erisu erisu left a comment

Choose a reason for hiding this comment

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

LGTM

@breautek
Copy link
Copy Markdown
Contributor

Looks good, thanks for the well documented PR and fix!

@breautek breautek merged commit 112f0a6 into apache:master Mar 17, 2022
@ltm ltm deleted the fix-detect-java11 branch March 21, 2022 14:48
wedgberto pushed a commit to wedgberto/cordova-android that referenced this pull request May 17, 2022
ebhsgit added a commit to ebhsgit/cordova-android that referenced this pull request May 25, 2022
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.

4 participants