Skip to content

Skip blank annotation processor names in javac and eclipse - #513

Open
slachiewicz wants to merge 3 commits into
masterfrom
javac-empty-annotation-processors
Open

Skip blank annotation processor names in javac and eclipse#513
slachiewicz wants to merge 3 commits into
masterfrom
javac-empty-annotation-processors

Conversation

@slachiewicz

@slachiewicz slachiewicz commented Aug 24, 2026

Copy link
Copy Markdown
Member

JavacCompiler and EclipseJavaCompiler both decided whether to pass -processor from the array's length alone, so an array of blank names produced -processor followed by an empty or comma-only argument. Fixes #512.

Both now route the field through one joinAnnotationProcessors helper on AbstractCompiler and emit the option only when a name survives. A single shared rule is the point: two hand-rolled guards that agree today drift apart tomorrow, which is how the two compilers came to disagree in the first place.

Filtering rather than length-checking is deliberate. {"", ""} has length 2, so a length guard still emits -processor ,. It also mirrors the semantic that apache/maven-compiler-plugin#1077 just merged caller-side, so behaviour is the same whether or not a user's plugin version carries that fix.

Compatibility

Every input whose behaviour changes — {""}, {"", ""}, {"", "X"} — previously made javac fail on an unresolvable processor name, so no working configuration depended on the old output.

One semantic worth stating: -processor suppresses javac's default ServiceLoader discovery, so omitting the option for an all-blank list restores discovery. That is the intended reading, since an empty element means "unspecified" rather than "none" — <proc>none</proc> remains the way to ask for no annotation processing, and it is an independent flag.

If reviewers would rather blanks were not dropped silently, a warn-level log line when the filter removes something would be a small follow-up.

Verified: mvn -pl plexus-compilers/plexus-compiler-javac,plexus-compilers/plexus-compiler-eclipse -am test → 129 and 17 tests, no failures. The {"", ""} case fails on master and passes here.

This change was created with AI assistance.

JavacCompiler guarded the -processor flag on a null check alone, so a
zero-length array produced -processor followed by an empty argument and
javac failed to resolve the empty name. EclipseJavaCompiler already
guards on length as well; this aligns the two.

Fixes #512
@slachiewicz slachiewicz added the bug Something isn't working label Aug 24, 2026
Both compilers decided whether to pass -processor from the array's length
alone, so an array of blank names produced -processor with an empty or
comma-only argument. Filtering blanks covers the zero-length case too, and
matches how maven-compiler-plugin normalizes the same field caller-side.

Fixes #512
@slachiewicz

Copy link
Copy Markdown
Member Author

Widened after review: the length guard alone did not cover {"", ""}, which has length 2 and still produced -processor ,. Both compilers now skip blank names, which subsumes the zero-length case.

EclipseJavaCompiler is included because it had the same hole. Its length > 0 guard only ever protected the empty-array case, so aligning the two compilers means filtering in both rather than copying a guard that was already insufficient.

Filtering rather than all-or-nothing matches how maven-compiler-plugin normalizes the same field caller-side in apache/maven-compiler-plugin#1077, now merged.

Verified: mvn -pl plexus-compilers/plexus-compiler-javac,plexus-compilers/plexus-compiler-eclipse -am test → 129 and 17 tests, no failures. The {"", ""} test fails on the previous commit and passes on this one.

This comment was created with AI assistance.

@slachiewicz slachiewicz changed the title Skip -processor when the annotation processor array is empty Skip blank annotation processor names in javac and eclipse Aug 24, 2026
Both compilers had their own copy of the blank-filtering loop. Two guards
that agree today are how these two came to disagree in the first place, so
route both through joinAnnotationProcessors on AbstractCompiler.
@wilx

wilx commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JavacCompiler emits -processor with an empty argument for a zero-length annotationProcessors array

2 participants