You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Raymond Augé (JIRA)" <ji...@apache.org> on 2017/02/08 16:40:42 UTC
[jira] [Created] (FELIX-5530) Don't process methods declared on the
Annotation class
Raymond Augé created FELIX-5530:
-----------------------------------
Summary: Don't process methods declared on the Annotation class
Key: FELIX-5530
URL: https://issues.apache.org/jira/browse/FELIX-5530
Project: Felix
Issue Type: Bug
Components: Converter
Reporter: Raymond Augé
when converting annotations to Maps, don't handle the methods on the Annotation class, similar to how those from Object are ignored.
e.g.
{code:java}
Annotation annotation = (Annotation)...;
Map<String, Object> map = c.convert(annotation).sourceAs(
annotation.annotationType()).to(
new TypeReference<Map<String, Object>>(){});
{code}
In the above case the detection of properties should include a check like so:
{code:java}
if (Object.class.equals(md.getDeclaringClass()) ||
Annotation.class.equals(md.getDeclaringClass()))
return null; // do not use any methods on the Object or Annotation class as a accessor
{code}
to avoid creating properties for annotationType, equals, hashCode, and toString (which in it's case are methods declared on the Annotation.class not Object.class).
Also note that it should be made clear when handling annotations that the {{sourceAs}} modifier should always be used with the result of {{annotation.annotationType()}} result because the {{getClass}} of an annotation object always returns the proxy class and not the Annotation type which confuses the converter.
e.g.
{code:java}
.sourceAs(annotation.annotationType()).to(...)
{code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)