[cdi-dev] [JBoss JIRA] (CDI-630) Revise javax.enterprise.util.AnnotationLiteral.cachedHashCode

Matej Novotny (JIRA) issues at jboss.org
Tue Sep 13 02:18:00 EDT 2016

    [ https://issues.jboss.org/browse/CDI-630?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13292251#comment-13292251 ] 

Matej Novotny commented on CDI-630:

So, if I get this right, then we are basically stuck here because our {{hashCode}} impl has to be alligned with that defined by {{java.lang.annotation.Annotation}}?
And the reason behind that is that people are able to use both approaches ({{class.getAnnotation}} and {{AnnotationLiteral}}) and the results would then differ.

> Revise javax.enterprise.util.AnnotationLiteral.cachedHashCode
> -------------------------------------------------------------
>                 Key: CDI-630
>                 URL: https://issues.jboss.org/browse/CDI-630
>             Project: CDI Specification Issues
>          Issue Type: Feature Request
>            Reporter: Martin Kouba
>             Fix For: 2.0 (discussion)
> Currently, {{AnnotationLiteral.hashCode()}} always returns {{0}} if there are no members (ignoring annotation type completely). Although it does not break {{Object.hashCode()}} contract, I believe we should either return a number based on the annotation type (to make the annotation literal instances more usable in hash tables) or simply return zero and don't cache the value at all.

This message was sent by Atlassian JIRA

More information about the cdi-dev mailing list