Skip to content

Pass -proc option to ECJ without explicit annotation processors - #529

Merged
slachiewicz merged 1 commit into
codehaus-plexus:masterfrom
RoiSoleil:fix/ecj-proc-without-explicit-processors
Nov 6, 2026
Merged

slachiewicz merged 1 commit into
codehaus-plexus:masterfrom
RoiSoleil:fix/ecj-proc-without-explicit-processors

Conversation

@RoiSoleil

@RoiSoleil RoiSoleil commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

EclipseJavaCompiler only passed -proc:<value> to ECJ when an explicit annotation processor, processor path, or processor module path was configured. As a result, <proc>none</proc> and <proc>only</proc> were ignored in the common case where processors are discovered from the classpath. ECJ could then try to load an unavailable processor and fail with ServiceConfigurationError.

This moves the config.getProc() handling outside the condition that requires explicit processor configuration, while keeping it inside the existing !isPreJava1_6(config) block.

Fixes #528.

Tests

Added regression tests in EclipseJavaCompilerTest:

  • procNoneDisablesAnnotationProcessorDiscoveryWithoutExplicitProcessors compiles a source with proc = none while an invalid META-INF/services/javax.annotation.processing.Processor is present on the output classpath. It fails before this change with ServiceConfigurationError and succeeds after it.
  • procOnlyIsPassedToEcjWithoutExplicitProcessors checks that proc = only prevents class generation.

Validation performed with JDK 21, Maven 3.9.12, and ECJ 3.46.100:

  • Targeted tests before the fix: 2 failures.
  • Targeted tests after the fix: 5 tests, 0 failures.
  • mvn -pl plexus-compilers/plexus-compiler-eclipse -am test: success (Eclipse module: 19 tests; API module: 18 tests).
  • spotless:check and git diff --check: clean.

The integration-test module was not run.

-proc:<value> was only added inside the block guarding explicit annotation
processors and processor paths. With <proc>none</proc> (or only) and none
of those options set, the option was therefore silently dropped and ECJ
still discovered processors from META-INF/services on the classpath.

Move the -proc handling after that conditional block, while keeping it in
the Java 6+ branch. Behavior without proc is unchanged, and explicit
processor arguments keep their existing order.

Add regression tests using real ECJ compilations for -proc:none (invalid
service provider must not be loaded) and -proc:only (sources must not be
compiled).
@RoiSoleil
RoiSoleil marked this pull request as ready for review October 24, 2026 19:04
@RoiSoleil
RoiSoleil marked this pull request as draft October 24, 2026 19:12
@RoiSoleil
RoiSoleil marked this pull request as ready for review October 24, 2026 20:19
@slachiewicz slachiewicz added the bug Something isn't working label Oct 25, 2026
@RoiSoleil

Copy link
Copy Markdown
Contributor Author

@slachiewicz could you review this one when you have a moment? It is a 3-line move in EclipseJavaCompiler: -proc:<value> was only passed to ECJ when explicit processors or a processor path were configured, so <proc>none</proc> and <proc>only</proc> were ignored when the processors are discovered on the classpath (#528). Builds without <proc> are unchanged, and the two new tests in EclipseJavaCompilerTest fail without the fix. Thanks!

@slachiewicz

Copy link
Copy Markdown
Member

Thank you @RoiSoleil! The change correctly moves handling outside the explicit annotation processors block so options like and are passed to ECJ as expected. Test coverage is clean. Ready to merge.

@slachiewicz
slachiewicz merged commit 9d3498e into codehaus-plexus:master Nov 6, 2026
30 checks passed
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.

plexus-compiler-eclipse: <proc>none</proc> is not passed to ECJ (annotation processors still discovered)

2 participants