felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raymond Augé (JIRA) <j...@apache.org>
Subject [jira] [Created] (FELIX-5530) Don't process methods declared on the Annotation class
Date Wed, 08 Feb 2017 16:40:42 GMT
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.

Annotation annotation = (Annotation)...;
Map<String, Object> map = c.convert(annotation).sourceAs(
    new TypeReference<Map<String, Object>>(){});

In the above case the detection of properties should include a check like so:
        if (Object.class.equals(md.getDeclaringClass()) ||
            return null; // do not use any methods on the Object or Annotation class as a
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.


This message was sent by Atlassian JIRA

View raw message