Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make error_prone_annotations dependency optional #1739

Closed

Conversation

HannesWell
Copy link
Contributor

@HannesWell HannesWell commented May 11, 2023

At the moment the error_prone_annotations are a mandatory requirement. But annotations with retention policy 'runtime' are ignored if they cannot be loaded at runtime (at least according to Stack-Overvflow). This PR aims to make the dependency optional to not enforce the presence of error_prone_annotations in a java runtime if those annotations are not used at all.

This is especially useful for OSGi-runtimes where you cannot exclude error_prone_annotations because the corresponding package is specified as mandatory requirement in the MANIFEST.MF. Marking the Maven dependency as optional will also result in the error-prone package requirement being marked as optional.

At the moment error_prone_annotations does not come with a OSGi compliant Manifest, which makes it harder to include it in OSGi applications like Eclipse.
I already created a PR at error-prone to include the required OSGi headers (see google/error-prone#3903), but not requiring the annotations at all would make it even simpler to use guice within OSGi.

Alternatively the dependency could only be marked as optional in the OSGi metadata.

Annotations with retention policy are ignored if they cannot be loaded
at runtime. Make the dependency optional to not enforce the presence of
error_prone_annotations in a java runtime even if those annotations are
not used at all.
@sameb
Copy link
Member

sameb commented May 11, 2023

Thanks @HannesWell . If an alternative is proper OSGi info in error prone, could you update a PR there for doing that and let me know when it's updated? I can try to nudge folks internally.

@HannesWell
Copy link
Contributor Author

Thanks @HannesWell . If an alternative is proper OSGi info in error prone, could you update a PR there for doing that and let me know when it's updated? I can try to nudge folks internally.

The PR is already there, it is google/error-prone#3903
It would be great if you make them aware of it. Thanks in advance. :)

@sameb
Copy link
Member

sameb commented May 12, 2023

(FYI, I locally confirmed that running binaries that reference the errorprone annotations, even reflectively iterating through annotations & annotation of annotations) works just fine if the annotation isn't on the classpath at runtime.)

@HannesWell
Copy link
Contributor Author

(FYI, I locally confirmed that running binaries that reference the errorprone annotations, even reflectively iterating through annotations & annotation of annotations) works just fine if the annotation isn't on the classpath at runtime.)

Great, thanks for that.
And thanks a lot for reviewing and merging this PR just in time for Guice 6/7 as well as for the help in error-prone (I assume you reached your college).

@HannesWell HannesWell deleted the optionalErrorproneAnnotations branch May 14, 2023 23:49
ThePumpingLemma added a commit to ThePumpingLemma/misk that referenced this pull request Jul 6, 2023
The annotations are not required by Guice at runtime, see
google/guice#1739
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants