Skip to content

Commit

Permalink
reconcile eclipse-jdt#3487
Browse files Browse the repository at this point in the history
with eclipse-jdt#3586
regarding @deprecated(since="18")

Improve splitting of string command line
  • Loading branch information
stephan-herrmann committed Jan 30, 2025
1 parent 9f9762b commit 71b9831
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ static class JavacCompiler {
this.compliance = CompilerOptions.versionToJdkLevel(this.version);
this.minor = minorFromRawVersion(this.version, rawVersion);
this.rawVersion = rawVersion;
this.classpath = "-classpath ";
this.classpath = " -classpath ";
}
/** Call this if " -classpath " should be replaced by some other option token. */
protected void usePathOption(String option) {
Expand Down Expand Up @@ -267,7 +267,7 @@ static String getVersion(String javacPathName) throws IOException, InterruptedEx
static String getBuild(String javaPathName) throws IOException, InterruptedException {
Process fetchVersionProcess = null;
try {
fetchVersionProcess = Runtime.getRuntime().exec(javaPathName + " -version", env, null);
fetchVersionProcess = Runtime.getRuntime().exec(new String[] {javaPathName , "-version"}, env, null);
Logger versionStdErrLogger = new Logger(fetchVersionProcess.getErrorStream(), ""); // for javac <= 1.8
Logger versionStdOutLogger = new Logger(fetchVersionProcess.getInputStream(), ""); // for javac >= 9
versionStdErrLogger.start();
Expand Down Expand Up @@ -613,7 +613,7 @@ long compile(File directory, String options, String[] sourceFileNames, StringBui
} else {
cmdLineAsString = cmdLine.toString();
}
compileProcess = Runtime.getRuntime().exec(cmdLineAsString.split("\\s"), env, directory);
compileProcess = Runtime.getRuntime().exec(cmdLineAsString.split("\\s+"), env, directory);
Logger errorLogger = new Logger(compileProcess.getErrorStream(),
"ERROR", log == null ? new StringBuilder() : log);
errorLogger.start();
Expand Down Expand Up @@ -4180,9 +4180,9 @@ private void setupJavac() throws Exception {
javaCommandLineHeader = cmdLineHeader.toString();
cmdLineHeader = new StringBuilder(jdkRootDirPath.
append("bin").append(JAVAC_NAME).toString());
String version = JavacCompiler.getVersion(cmdLineHeader.toString());
cmdLineHeader.append(" -classpath . ");
// start with the current directory which contains the source files
String version = JavacCompiler.getVersion(cmdLineHeader.toString());
cmdLineHeader.append(" -d ");
cmdLineHeader.append(JAVAC_OUTPUT_DIR_NAME.indexOf(" ") != -1 ? "\"" + JAVAC_OUTPUT_DIR_NAME + "\"" : JAVAC_OUTPUT_DIR_NAME);
String firstSupportedVersion = CompilerOptions.getFirstSupportedJavaVersion();
Expand Down

0 comments on commit 71b9831

Please sign in to comment.