8318811: Compiler directives parser swallows a character after line comments

Backport-of: 141dae8b76
This commit is contained in:
Satyen Subramaniam
2025-05-10 02:42:10 +00:00
committed by Vitaly Provodin
parent fed7bfe117
commit 2b437db473
2 changed files with 21 additions and 1 deletions

View File

@@ -580,7 +580,7 @@ u_char JSON::skip_line_comment() {
return 0;
}
next();
return next();
return peek();
}
/*

View File

@@ -33,6 +33,9 @@
package compiler.compilercontrol.parser;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import compiler.compilercontrol.share.JSONFile;
import jdk.test.lib.Asserts;
import jdk.test.lib.process.OutputAnalyzer;
@@ -52,6 +55,7 @@ public class DirectiveParserTest {
emptyFile();
noFile();
directory();
lineCommentTest();
}
private static void simpleTest() {
@@ -145,4 +149,20 @@ public class DirectiveParserTest {
Asserts.assertNE(output.getExitValue(), 0, ERROR_MSG + "directory as "
+ "a name");
}
private static void lineCommentTest() {
String fileName = "lineComment.json";
try {
PrintStream out = new PrintStream(fileName);
out.println("[{");
out.println(" match: \"*::*\",");
out.println(" c2: { Exclude: true } // c1 only for startup");
out.println("}]");
out.close();
} catch (FileNotFoundException e) {
throw new Error("TESTBUG: can't open/create file " + fileName, e);
}
OutputAnalyzer output = HugeDirectiveUtil.execute(fileName);
output.shouldHaveExitValue(0);
}
}