felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Bosschaert (JIRA)" <j...@apache.org>
Subject [jira] [Assigned] (FELIX-5530) Don't process methods declared on the Annotation class
Date Wed, 08 Feb 2017 22:14:41 GMT

     [ https://issues.apache.org/jira/browse/FELIX-5530?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

David Bosschaert reassigned FELIX-5530:

    Assignee: David Bosschaert

> 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é
>            Assignee: David Bosschaert
> 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

View raw message