This repository was archived by the owner on Feb 2, 2021. It is now read-only.
Fix detection of Javac version#1037
Merged
rosen-vladimirov merged 2 commits intomasterfrom Jan 3, 2018
Merged
Conversation
The command `javac -version` prints result to stderr when JAVA 8 is used and to stdout when JAVA 9 is used. Current check in CLI uses the stderr output, so when JAVA 9 is installed it fails to detect the correct version. In order to support both JAVA 8 and JAVA 9, capture both stdout and stderr and get the version from there. Also remove unneeded check for Java version - we care about JAVA Compiler, which is included in JDK.
This was referenced Dec 29, 2017
Plamen5kov
reviewed
Dec 29, 2017
| }); | ||
|
|
||
| it("returns correct javac version when it is printed on stdout (Java 9)", () => { | ||
| return verifyJavaCompilerVersion("9.0.1", "stdout"); |
Contributor
There was a problem hiding this comment.
@rosen-vladimirov some distributions of java return 9 when java -version is called, in which case I think the regex might break. I haven't tested it but I encountered such an issue in the past.
Collaborator
Author
There was a problem hiding this comment.
Thanks for pointing this. In case 9 is returned, the current code will work fine, but this one will fail. I'll handle the case there.
Collaborator
Author
There was a problem hiding this comment.
@Plamen5kov fixed in this PR NativeScript/nativescript-cli#3294
Contributor
There was a problem hiding this comment.
@rosen-vladimirov I tested it, and CLI provides a message to install java 1.8.0.
Improve `appendZeroesToVersion` method to return the passed value in case it is null, undefined or empty string and add tests for the method.
Mitko-Kerezov
approved these changes
Jan 3, 2018
Contributor
Mitko-Kerezov
left a comment
There was a problem hiding this comment.
Looks all right to me
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
The command
javac -versionprints result to stderr when JAVA 8 is used and to stdout when JAVA 9 is used. Current check in CLI uses the stderr output, so when JAVA 9 is installed it fails to detect the correct version.In order to support both JAVA 8 and JAVA 9, capture both stdout and stderr and get the version from there.
Also remove unneeded check for Java version - we care about JAVA Compiler, which is included in JDK.