Skip to content

Min supported Java version check added #1820

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/android-tools-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {

public validateJavacVersion(installedJavaVersion: string, options?: { showWarningsAsErrors: boolean }): IFuture<boolean> {
return ((): boolean => {
// Check for min supported Java version
let minJavaVersion = "1.8";
Copy link
Contributor

Choose a reason for hiding this comment

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

is there any reason to add this code, several lines below there's a check for currently installed version and verification against AndroidToolsInfo.MIN_JAVA_VERSION
Can't you just set MIN_JAVA_VERSION to 1.8.0 and do not change anything in this method?

if (parseInt(installedJavaVersion.substr(0, 3).replace(".", "")) < parseInt(minJavaVersion.replace(".", ""))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This could fail on several places, installedJavaVersion could be null or undefined.
parseInt could return NaN

this.printMessage(`Java version ${installedJavaVersion} is not supported. You have to install at least ${minJavaVersion}.`);
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

when there's an error you should return true, check the code below

}

let hasProblemWithJavaVersion = false;
if (options) {
this.showWarningsAsErrors = options.showWarningsAsErrors;
Expand All @@ -170,7 +177,7 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
if (matchingVersion && matchingVersion[1]) {
if (semver.lt(matchingVersion[1], AndroidToolsInfo.MIN_JAVA_VERSION)) {
hasProblemWithJavaVersion = true;
this.printMessage(`Javac version ${installedJavaVersion} is not supported. You have to install at least ${AndroidToolsInfo.MIN_JAVA_VERSION}.`, additionalMessage);
this.printMessage(`Java version ${installedJavaVersion} is not supported. You have to install at least ${AndroidToolsInfo.MIN_JAVA_VERSION}.`, additionalMessage);
}
} else {
hasProblemWithJavaVersion = true;
Expand Down