Skip to content

Commit 71b9831

Browse files
reconcile eclipse-jdt#3487
with eclipse-jdt#3586 regarding @deprecated(since="18") Improve splitting of string command line
1 parent 9f9762b commit 71b9831

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ static class JavacCompiler {
229229
this.compliance = CompilerOptions.versionToJdkLevel(this.version);
230230
this.minor = minorFromRawVersion(this.version, rawVersion);
231231
this.rawVersion = rawVersion;
232-
this.classpath = "-classpath ";
232+
this.classpath = " -classpath ";
233233
}
234234
/** Call this if " -classpath " should be replaced by some other option token. */
235235
protected void usePathOption(String option) {
@@ -267,7 +267,7 @@ static String getVersion(String javacPathName) throws IOException, InterruptedEx
267267
static String getBuild(String javaPathName) throws IOException, InterruptedException {
268268
Process fetchVersionProcess = null;
269269
try {
270-
fetchVersionProcess = Runtime.getRuntime().exec(javaPathName + " -version", env, null);
270+
fetchVersionProcess = Runtime.getRuntime().exec(new String[] {javaPathName , "-version"}, env, null);
271271
Logger versionStdErrLogger = new Logger(fetchVersionProcess.getErrorStream(), ""); // for javac <= 1.8
272272
Logger versionStdOutLogger = new Logger(fetchVersionProcess.getInputStream(), ""); // for javac >= 9
273273
versionStdErrLogger.start();
@@ -613,7 +613,7 @@ long compile(File directory, String options, String[] sourceFileNames, StringBui
613613
} else {
614614
cmdLineAsString = cmdLine.toString();
615615
}
616-
compileProcess = Runtime.getRuntime().exec(cmdLineAsString.split("\\s"), env, directory);
616+
compileProcess = Runtime.getRuntime().exec(cmdLineAsString.split("\\s+"), env, directory);
617617
Logger errorLogger = new Logger(compileProcess.getErrorStream(),
618618
"ERROR", log == null ? new StringBuilder() : log);
619619
errorLogger.start();
@@ -4180,9 +4180,9 @@ private void setupJavac() throws Exception {
41804180
javaCommandLineHeader = cmdLineHeader.toString();
41814181
cmdLineHeader = new StringBuilder(jdkRootDirPath.
41824182
append("bin").append(JAVAC_NAME).toString());
4183+
String version = JavacCompiler.getVersion(cmdLineHeader.toString());
41834184
cmdLineHeader.append(" -classpath . ");
41844185
// start with the current directory which contains the source files
4185-
String version = JavacCompiler.getVersion(cmdLineHeader.toString());
41864186
cmdLineHeader.append(" -d ");
41874187
cmdLineHeader.append(JAVAC_OUTPUT_DIR_NAME.indexOf(" ") != -1 ? "\"" + JAVAC_OUTPUT_DIR_NAME + "\"" : JAVAC_OUTPUT_DIR_NAME);
41884188
String firstSupportedVersion = CompilerOptions.getFirstSupportedJavaVersion();

0 commit comments

Comments
 (0)