diff options
author | David Herman <davidherman@google.com> | 2014-11-24 11:20:35 -0800 |
---|---|---|
committer | David Herman <davidherman@google.com> | 2014-11-24 11:23:36 -0800 |
commit | 633339d82e0da9cafa9b2ccea46b9375ad64d668 (patch) | |
tree | 925269379fe501fcd7034453a83f0a3f31db16e9 /find_java/src | |
parent | fd8c9bbc6e0d60ceed257c44bb20c4a31b500acb (diff) | |
download | sdk-633339d82e0da9cafa9b2ccea46b9375ad64d668.zip sdk-633339d82e0da9cafa9b2ccea46b9375ad64d668.tar.gz sdk-633339d82e0da9cafa9b2ccea46b9375ad64d668.tar.bz2 |
Fixed find_java JAVA_HOME minimum version bug
If a minimum version is specified, Find Java should reject any
java whose version is not at least that high. However, faulty
logic ignored this contract when reading an old Java path out of
the JAVA_HOME environment variable.
Related to issue:
https://code.google.com/p/android/issues/detail?id=80419
Change-Id: Iad935694e5b143f53074d28b8c8d7f087f9690e4
Diffstat (limited to 'find_java/src')
-rwxr-xr-x | find_java/src/source/find_java_lib.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/find_java/src/source/find_java_lib.cpp b/find_java/src/source/find_java_lib.cpp index 134c38b..4da645c 100755 --- a/find_java/src/source/find_java_lib.cpp +++ b/find_java/src/source/find_java_lib.cpp @@ -152,28 +152,25 @@ int findJavaInPath(const CPath &path, CPath *outJavaPath, bool isJdk, int minVer int findJavaInEnvPath(CPath *outJavaPath, bool isJdk, int minVersion) {
SetLastError(0);
- int currVersion = 0;
-
const char* envPath = getenv("JAVA_HOME");
if (envPath != NULL) {
CPath p(envPath);
if (!isJdk || isJdkPath(p)) {
- currVersion = checkBinPath(&p);
- if (currVersion > 0) {
+ int v = checkBinPath(&p);
+ if (v >= minVersion) {
if (gIsDebug) {
- fprintf(stderr, "Java %d found via JAVA_HOME: %s\n", currVersion, p.cstr());
+ fprintf(stderr, "Java %d found via JAVA_HOME: %s\n", v, p.cstr());
}
*outJavaPath = p;
- }
- if (currVersion >= minVersion) {
// As an optimization for runtime, if we find a suitable java
// version in JAVA_HOME we won't waste time looking at the PATH.
- return currVersion;
+ return v;
}
}
}
+ int currVersion = 0;
envPath = getenv("PATH");
if (!envPath) return currVersion;
|