-
Notifications
You must be signed in to change notification settings - Fork 58
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
JavacCompiler forked compilation fails with no messages and no other output #66
Comments
I encountered a similar problem where valuable information from stderr is ignored:
So its not just about potential stackoverflow bugs in javac. There are also error cases where erroneous input data can cause javac to detect actual errors that should be recognized be the plexus-compiler. |
Would also be great if in addition to that there was a opt-in setting (which would then also be propagated to the Maven Compiler Plugin) which always prints the complete process output on error, regardless of whether some diagnostics were found in the output or not. That would help in case plexus-compiler only detected some but not all diagnostics in the output. For example for the following warnings about missing annotation classes (JDK-6365854), plexus-compiler did not detect any warnings or errors:
Or maybe
Or is there output which should be ignored from the compiler? |
I had a Java class using a builder pattern to put together a lookup table. There was another class which chained together 600+ method calls on a single line on this builder, assembling the table. Understandably, as the number of entries in the lookup table grew, we eventually ran into a
StackOverflowError
fromjavac
while compiling the class.javac
does not handle this gracefully; the SOE stacktrace is written to stderr with no surrounding context clues, and then the compiler exits.The project is built using Maven, which of course uses
plexus-compiler-javac
. We run the build in forked mode.Unfortunately, the Plexus compiler recognizes the forked build as failed, but does not capture the cause. There are no messages on the
CompilerResult
, and nothing is printed to stdout/stderr. It was therefore quite difficult for me to diagnose the cause of the compilation failure. By enabling verbose mode, I was able to see the compiler's progress, and through process of elimination I identified the problematic class. One look at the class led me to suspect an SOE, which I was able to verify by compiling the class manually at the command line. From there, it was a simple matter of splitting up the line of code into multiple lines.I have created an MVCE here: https://github.com/jakerobb/plexus-javac-compiler-bug. It's a small Maven project. Just clone it and run
mvn test
to reproduce the issue.I think that #39 would have been helpful here, but I also think that some other improvements are called for:
Of course, ideally, javac should be fixed to not throw an SOE in this scenario, probably by replacing recursion with iteration, and also to write out the file it was working on when compilation fails. I'm now off to figure out how to report an improvement request in javac....
The text was updated successfully, but these errors were encountered: