[
https://issues.jboss.org/browse/CDI-631?page=com.atlassian.jira.plugin.sy...
]
Martin Kouba commented on CDI-631:
----------------------------------
For the record - {{AnnotationLiteral#hashCode()}} is already optimized for annotations
with no members (see also
https://github.com/cdi-spec/cdi/blob/master/api/src/main/java/javax/enter...),
the same applies to {{#equals()}}. {{#toString()}} is not cached and I don't think it
should be (by the way it's not even cached in the referenced OWB's
{{EmptyAnnotationLiteral}}).
Also I don't think we should cache hashCode and toString for annotations with members
- it could work in most cases but it's not 100%.
Improve AnnotationLiteral for empty annotations
-----------------------------------------------
Key: CDI-631
URL:
https://issues.jboss.org/browse/CDI-631
Project: CDI Specification Issues
Issue Type: Feature Request
Reporter: Mark Struberg
Fix For: 2.0 (discussion)
Annotation hashCode() and equals() operations are fairly expensive as they always invoke
getDeclaredMethods() even if there are no such. And getDeclaredMethods involves the
SecurityManager + wrapper classes + Exception handling + + +
That's horrible expensive.
In OWB I improved this by introducing an own base class for dynamic annotations which do
not have any members:
https://github.com/apache/openwebbeans/blob/trunk/webbeans-impl/src/main/...
The method returns a hardcoded String for toString(), returns hardcoded 0 as hashCode and
the equals() method invokes the equals on the annotation type.
We might support this improvements directly in the AnnotationLiteral class or introduce a
similar 2nd class especially for empty annotations?
--
This message was sent by Atlassian JIRA
(v7.2.2#72004)