Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report "Error occurred during initialization of VM" as error #343

Merged
merged 1 commit into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,10 @@ private static CompilerResult compileInProcess0(Class<?> javacClass, String[] ar
private static final Pattern STACK_TRACE_OTHER_LINE =
Pattern.compile("^(?:Caused by:\\s.*|\\s*at .*|\\s*\\.\\.\\.\\s\\d+\\smore)$");

// Match generic javac errors with 'javac:' prefix, JMV init and boot layer init errors
private static final Pattern JAVAC_OR_JVM_ERROR =
Pattern.compile("^(?:javac:|Error occurred during initialization of (?:boot layer|VM)).*", Pattern.DOTALL);

/**
* Parse the output from the compiler into a list of CompilerMessage objects
*
Expand All @@ -664,10 +668,8 @@ static List<CompilerMessage> parseModernStream(int exitCode, BufferedReader inpu
// maybe better to ignore only the summary and mark the rest as error
String bufferAsString = buffer.toString();
if (buffer.length() > 0) {
if (bufferAsString.startsWith("javac:")) {
if (JAVAC_OR_JVM_ERROR.matcher(bufferAsString).matches()) {
errors.add(new CompilerMessage(bufferAsString, CompilerMessage.Kind.ERROR));
} else if (bufferAsString.startsWith("Error occurred during initialization of boot layer")) {
errors.add(new CompilerMessage(bufferAsString, CompilerMessage.Kind.OTHER));
} else if (hasPointer) {
// A compiler message remains in buffer at end of parse stream
errors.add(parseModernError(exitCode, bufferAsString));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1010,16 +1010,29 @@ public void testIssue37() throws IOException {
}

@Test
public void testJvmError() throws Exception {
public void testJvmBootLayerInitializationError() throws Exception {
String out = "Error occurred during initialization of boot layer" + EOL
+ "java.lang.module.FindException: Module java.xml.bind not found";

List<CompilerMessage> compilerErrors =
JavacCompiler.parseModernStream(1, new BufferedReader(new StringReader(out)));

assertThat(compilerErrors, notNullValue());
assertThat(compilerErrors.size(), is(1));
assertThat(compilerErrors.get(0).getKind(), is(CompilerMessage.Kind.ERROR));
}

@Test
public void testJvmInitializationError() throws Exception {
String out = "Error occurred during initialization of VM" + EOL
+ "Initial heap size set to a larger value than the maximum heap size";

List<CompilerMessage> compilerErrors =
JavacCompiler.parseModernStream(1, new BufferedReader(new StringReader(out)));

assertThat(compilerErrors, notNullValue());
assertThat(compilerErrors.size(), is(1));
assertThat(compilerErrors.get(0).getKind(), is(CompilerMessage.Kind.ERROR));
}

@Test
Expand Down