JavacCompiler decides whether to pass -processor by a null check alone, so a zero-length annotationProcessors array produces -processor followed by an empty argument. javac then fails because the empty processor name cannot be resolved.
JavacCompiler.java, in buildCompilerArguments:
if (config.getAnnotationProcessors() != null) {
args.add("-processor");
String[] procs = config.getAnnotationProcessors();
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < procs.length; i++) {
if (i > 0) {
buffer.append(",");
}
buffer.append(procs[i]);
}
args.add(buffer.toString());
}
With procs.length == 0 the buffer stays empty and the emitted arguments are -processor and "".
EclipseJavaCompiler guards the same field differently and is unaffected:
if (annotationProcessors != null && annotationProcessors.length > 0) {
That difference is why the failure only reproduces under javac.
How it surfaces
Maven maps an explicitly empty <annotationProcessors/> block to an array holding one blank string rather than to an empty array or null, so maven-compiler-plugin hands the array straight through and the build fails. That is MCOMPILER-607, and apache/maven-compiler-plugin#1077 works around it by normalizing the array to null before it reaches Plexus Compiler.
The workaround is correct and worth merging on its own, but it lives in one caller. Any other caller that builds a CompilerConfiguration with an empty processor array reaches the same -processor "".
Suggested change
Match EclipseJavaCompiler by adding the length check. Two compilers currently disagree about the meaning of the same field, and aligning them removes the class of bug rather than one instance of it.
This issue was created with AI assistance.
JavacCompilerdecides whether to pass-processorby a null check alone, so a zero-lengthannotationProcessorsarray produces-processorfollowed by an empty argument.javacthen fails because the empty processor name cannot be resolved.JavacCompiler.java, inbuildCompilerArguments:With
procs.length == 0the buffer stays empty and the emitted arguments are-processorand"".EclipseJavaCompilerguards the same field differently and is unaffected:That difference is why the failure only reproduces under
javac.How it surfaces
Maven maps an explicitly empty
<annotationProcessors/>block to an array holding one blank string rather than to an empty array ornull, so maven-compiler-plugin hands the array straight through and the build fails. That is MCOMPILER-607, and apache/maven-compiler-plugin#1077 works around it by normalizing the array tonullbefore it reaches Plexus Compiler.The workaround is correct and worth merging on its own, but it lives in one caller. Any other caller that builds a
CompilerConfigurationwith an empty processor array reaches the same-processor "".Suggested change
Match
EclipseJavaCompilerby adding the length check. Two compilers currently disagree about the meaning of the same field, and aligning them removes the class of bug rather than one instance of it.This issue was created with AI assistance.