-
Enhancement
-
Resolution: Fixed
-
P4
-
20
-
b19
-
generic
-
generic
JSR 269 introduced annotation processing into Java.
However it was implemented that this is enabled by default inside the compiler and can be disabled with -proc:none flag. Annotation processors are also loaded via ServiceLoader.
The implementation happened nearly 20 years ago, in a time when build tools like Ant, Maven and Gradle had no widespread usage or didn't even exist yet.
Based on my observations, nowadays annotation processing is hardly used anymore and if it's used it mostly occurs after the actual compilation process in a build tool - with a specific Annotation Processor only.
Furthermore - because it's enabled by default - it may expose the user to a risk of unintentional executing code that should only be compiled.
Consider the following scenario:
* A new version of a library - used inside one of your programs maybe only transitively - get's released. However it is infected with a malicious annotation processor.
* The new version is picked up by your automated dependency update tool (e.g. https://github.com/renovatebot/renovate or https://github.com/dependabot) and a PullRequest is created
* The PR is picked up by a CI server which compiles the code to check if everything works
* When compiling the code the malicious annotation processor is executed and it may compromise your CI server
The above scenario can easily be mitigated with the -proc:none Flag, however as annotation processing usually occurs without any log outputs or additional hints, it's likely that most users don't even know that it's enabled by default.
So maybe it would be a good idea to disable annotation processing by default and enable it only when e.g. the -proc (without Arguments) Flag is set. This would be a breaking change, however it may be acceptable considering that the security improvements for most users outweigh the effort of some users to add a simple flag.
- csr for
-
JDK-8317544 Consider disabling the compiler's default active annotation processing
- Closed
- relates to
-
CODETOOLS-7903596 JMH: Explicitly enable annotation processors
- In Progress
-
JDK-8317802 jmh tests fail with Unable to find the resource: /META-INF/BenchmarkList after JDK-8306819
- Resolved
-
JDK-8310061 Note if implicit annotation processing is being used
- Resolved
-
JDK-8309870 Using -proc:full should be considered requesting explicit annotation processing
- Resolved
-
JDK-6378954 Update annotation processor to use standard Service provider mechanism
- Closed
-
JDK-8321073 Defer policy of disabling annotation processing by default
- Resolved
-
JDK-8321314 Reinstate disabling the compiler's default active annotation processing
- Resolved
-
JDK-8308245 Add -proc:full to describe current default annotation processing policy
- Resolved
-
JDK-8335404 javac implicit annotation processing warning should print processors
- New
- links to
-
Commit openjdk/jdk/dc4bc4f0
-
Review(master) openjdk/jdk/14432