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

Improve AnnotationLiteral javadoc #656

Closed
manovotn opened this issue Mar 7, 2023 · 1 comment · Fixed by #657
Closed

Improve AnnotationLiteral javadoc #656

manovotn opened this issue Mar 7, 2023 · 1 comment · Fixed by #657
Milestone

Comments

@manovotn
Copy link
Contributor

manovotn commented Mar 7, 2023

The javadoc of AnnotationLiteral should discourage instantiation using anonymous classes.

Definition of Annotation#equals, among other thing, says that:

returns true if the specified object is an instance of the same annotation interface as this instance

However, this can never be honored by anonymous class for AnnotationLiteral as it simply doesn't implement given annotation.
Standard class extending AnnotationLiteral can and does that just fine.

We could change the javadoc from saying just:

An instance of an annotation type may be obtained by subclassing AnnotationLiteral.

To something like:

An instance of an annotation type may be obtained by subclassing AnnotationLiteral.
The subclass must implement the annotation interface to satisfy the {@link Annotation} contract.

Side note: There are TCK tests that use anonymous AnnotationLiteral that we should look into as well. The change will be trivial.

@Ladicek
Copy link
Contributor

Ladicek commented Mar 7, 2023

To fix the TCK, I submitted jakartaee/cdi-tck#443

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 a pull request may close this issue.

2 participants