@@ -78,33 +78,30 @@ void JvmLauncher::setJavaCmd(const string cmdPath) {
78
78
javaServerDllPath = javaPath;
79
79
}
80
80
81
- bool JvmLauncher::checkJava (const char *path, const char *prefix) {
82
- assert (path);
81
+ bool JvmLauncher::checkJava (std::string &path, const char *prefix) {
83
82
assert (prefix);
84
- logMsg (" checkJava('%s', '%s')" , path, prefix);
83
+ logMsg (" checkJava('%s', '%s')" , path. c_str () , prefix);
85
84
86
- std::string tmp (path);
87
-
88
- if (*tmp.rbegin () == ' \\ ' ) {
89
- tmp.erase (tmp.length () - 1 , 1 );
85
+ if (*path.rbegin () == ' \\ ' ) {
86
+ path.erase (path.length () - 1 , 1 );
90
87
}
91
- javaExePath = tmp + prefix + JAVA_EXE_FILE;
92
- javawExePath = tmp + prefix + JAVAW_EXE_FILE;
93
- javaClientDllPath = tmp + prefix + JAVA_CLIENT_DLL_FILE;
94
- javaServerDllPath = tmp + prefix + JAVA_SERVER_DLL_FILE;
88
+ javaExePath = path + prefix + JAVA_EXE_FILE;
89
+ javawExePath = path + prefix + JAVAW_EXE_FILE;
90
+ javaClientDllPath = path + prefix + JAVA_CLIENT_DLL_FILE;
91
+ javaServerDllPath = path + prefix + JAVA_SERVER_DLL_FILE;
95
92
if (!fileExists (javaClientDllPath.c_str ())) {
96
93
javaClientDllPath = " " ;
97
94
}
98
95
if (!fileExists (javaServerDllPath.c_str ())) {
99
96
javaServerDllPath = " " ;
100
97
}
101
- javaBinPath = tmp + prefix + JAVA_BIN_DIR;
98
+ javaBinPath = path + prefix + JAVA_BIN_DIR;
102
99
if (fileExists (javaExePath.c_str ()) || !javaClientDllPath.empty () || !javaServerDllPath.empty ()) {
103
100
if (!fileExists (javawExePath.c_str ())) {
104
101
logMsg (" javaw.exe not exists, forcing java.exe" );
105
102
javawExePath = javaExePath;
106
103
}
107
- javaPath = tmp ;
104
+ javaPath = path ;
108
105
return true ;
109
106
}
110
107
@@ -119,10 +116,13 @@ bool JvmLauncher::checkJava(const char *path, const char *prefix) {
119
116
bool JvmLauncher::initialize (const char *javaPathOrMinVersion) {
120
117
logMsg (" JvmLauncher::initialize()\n\t javaPathOrMinVersion: %s" , javaPathOrMinVersion);
121
118
assert (javaPathOrMinVersion);
119
+
120
+ std::string pathOrVersion (javaPathOrMinVersion);
121
+
122
122
if (isVersionString (javaPathOrMinVersion)) {
123
123
return findJava (javaPathOrMinVersion);
124
124
} else {
125
- return (checkJava (javaPathOrMinVersion , JAVA_JRE_PREFIX) || checkJava (javaPathOrMinVersion , " " ));
125
+ return (checkJava (pathOrVersion , JAVA_JRE_PREFIX) || checkJava (pathOrVersion , " " ));
126
126
}
127
127
}
128
128
@@ -446,7 +446,7 @@ bool JvmLauncher::findJava(const char *javaKey, const char *prefix, const char *
446
446
if (*path.rbegin () == ' \\ ' ) {
447
447
path.erase (path.length () - 1 , 1 );
448
448
}
449
- return checkJava (path. c_str () , prefix);
449
+ return checkJava (path, prefix);
450
450
}
451
451
}
452
452
}
0 commit comments