Skip to content

Improve AnnotationLiteral javadoc #656

Closed
@manovotn

Description

@manovotn

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.

Activity

added this to the CDI 4.1/5.0 milestone on Mar 7, 2023
Ladicek

Ladicek commented on Mar 7, 2023

@Ladicek
Contributor

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Improve `AnnotationLiteral` javadoc · Issue #656 · jakartaee/cdi