What does the -proc / proc:none compiler option control, and when would you disable annotation processing?
answer
- proc:none = compile, no processors
- proc:only = process, no compile
- proc:full = JDK 21 explicit enable
- skips service-loader scan
- silences JDK 21 deprecation warning
basics
~10 sThe -proc flag controls whether javac runs annotation processing. proc:none compiles without running any processors; proc:only runs processors but skips compilation. Disable processing to speed builds or avoid unwanted code generation.
solid answer
~40 sjavac's `-proc` flag has three modes: default (process annotations AND compile), `proc:none` (compile only, skip all annotation processing), and `proc:only` (run processors but produce no class files). In the compiler plugin you set `<proc>none</proc>`. Disabling is useful when a module has no processors and you want to skip the discovery scan for speed, or to silence the JDK warning (newer JDKs warn that implicit processing is deprecated and will be disabled by default). Conversely, since JDK 21+ you must explicitly enable processing with `<proc>full</proc>` if you rely on classpath-discovered processors, because implicit processing is being phased out. proc:only is occasionally used in code-generation-only build steps.
code
xml · 7 lines<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<proc>none</proc>
</configuration>
</plugin>go deeper
Knows -proc controls whether annotation processors run during compilation.
Distinguishes none/only/full and knows proc:none compiles without processors.
Uses proc:none to speed clean modules and understands the JDK 21 deprecation of implicit discovery.
Sets an org-wide policy (explicit processor paths + proc settings) ahead of the JDK change disabling implicit processing.
## The -proc flag `javac -proc:<mode>` decides whether **annotation processing** happens. Modes: - **(default)** — run any discovered processors, then compile. - **`-proc:none`** — do NOT run processors; just compile. In the plugin: `<proc>none</proc>`. - **`-proc:only`** — run processors, generate their output, but do NOT compile the regular sources to `.class` files. - **`-proc:full`** (JDK 21+) — explicitly request full processing+compilation. ## Why disable processing (proc:none) - **Build speed**: skips the service-loader scan for processors on the classpath. In modules with no processors this is a tiny but free win and avoids surprises. - **Avoid accidental processing**: if a processor sits on the classpath transitively (e.g. an old Lombok), proc:none guarantees it won't run. - **Silence the JDK warning**: starting around JDK 21 javac emits `warning: Annotation processing is enabled because one or more processors were found on the class path. A future release of javac may disable annotation processing unless at least one processor is specified by name (-processor), or a search path is specified (--processor-path, --processor-module-path), or annotation processing is enabled explicitly (-proc:only, -proc:full).` Setting `-proc:none` (or moving processors to `--processor-path`) removes it. ## The JDK 21+ shift Implicit classpath discovery of processors is being deprecated. If you genuinely use processors via the classpath, you may need `<proc>full</proc>` or, better, declare them under `<annotationProcessorPaths>` so they are found explicitly. ## Configuration ```xml <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <proc>none</proc> </configuration> </plugin> ``` ## proc:only use case A build that only needs the generated artifacts (e.g. generating gRPC stubs or metadata) without producing application classes can use `proc:only`, though dedicated codegen plugins are more common.
- What is the difference between proc:none and proc:only?proc:none compiles but runs no processors; proc:only runs processors to generate output but does not produce regular class files.
- Why might you see a javac annotation-processing warning on JDK 21 and how do you fix it?Implicit classpath discovery is deprecated. Fix by moving processors to annotationProcessorPaths (--processor-path) or setting <proc>full</proc> if you really want them, or <proc>none</proc> if you don't.
saying these in an interview costs you the question
- Saying proc:none disables compilation — it disables processing, compilation still happens.
- Confusing proc:only (process, no compile) with proc:none (compile, no process).
- Assuming annotation processing is free; the discovery scan has a cost.