Fix: properly detect the @Generated annotation on JDK9 to avoid package splits #882
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Solution to #880.
The original issue was closed with a statement that the changes in 772374b would fix it. However, they do not. The JDK9 modular application would still have to deal with the package split, but instead of patching
java.xml.ws.annotation
, it would need to patchjsr250
. In addition, adding this dependency pollutes the application dependencies with (mostly unnecessary) JavaEE annotations.The solution:
javax.annotation.Generated
, which removes the need to add any extra dependencies, and effectively removes the package split.javax.annotation.processing.Generated
annotation.I tested the solution on my experimental application, where I added Jigsaw modules: https://github.com/zyxist/dagger-example-app
Use case 1:
Result: the generated classes are annotated with
javax.annotation.processing.Generated
.Use case 2:
Result: the generated classes are annotated with
javax.annotation.Generated
.Use case 3:
Result: the generated classes are not annotated.
Use case 4: using Dagger together with Guava (a library that depends on
jsr305
):Result: build successful, no patching needed.
For JDK8, the annotation processor will always detect
javax.annotation.Generated
.Please check if I correctly removed the jsr250 dependency from the build files. I'm new to Bazel, and I had some issues with running the full build due to the issues with Android SDK.
CLA is signed.