[JENKINS-67960] Work around MCOMPILER-346 #511
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
See JENKINS-67960 and MCOMPILER-346. I have run into this bug repeatedly while working on Jenkins, most recently in jenkinsci/acceptance-test-harness#733.
Problem
When compiling Jenkins code with compilation errors with Java 11, MCOMPILER-346 is frequently encountered. If you encounter it with
-source 8
, you get aNullPointerException
. If you encounter it with-source 11
, you get anAssertionError
. Either way, you do not get a readable message with the compilation error. Therefore, you have no idea what you need to fix in order to get the code to compile.Solution
TBD. MCOMPILER-346 has remained open since June 28, 2018. I submitted a Minimal Reproducible Example (MRE) hoping that this will help the Maven developers resolve the issue.
Workaround
In the past, I have worked around this issue by switching back to Java 8. This works with
-source 8
, but it does not work with-source 11
for obvious reasons. Therefore, a new workaround is needed. I have just discovered a new workaround: running Maven with-Dmaven.compiler.forceJavacCompilerUse=true
. Until MCOMPILER-346 is fixed, we should enable this workaround by default for all Jenkins builds. Otherwise, people compiling with Java 11 will get strangeNullPointerException
s orAssertionError
s when their code does not compile rather than a comprehensible error message explaining the source of the compilation error.Testing done
See jenkinsci/pom#235.