You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/02/08 16:53:41 UTC

[jira] [Commented] (FELIX-5530) Don't process methods declared on the Annotation class

    [ https://issues.apache.org/jira/browse/FELIX-5530?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15858221#comment-15858221 ] 

ASF GitHub Bot commented on FELIX-5530:
---------------------------------------

GitHub user rotty3000 opened a pull request:

    https://github.com/apache/felix/pull/91

    FELIX-5530 Don't process methods declared on the Annotation class

    Signed-off-by: Raymond Augé <ro...@apache.org>

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/rotty3000/felix FELIX-5530

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/felix/pull/91.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #91
    
----
commit bee87e64f42d53778014cfb327151d4ad9d8fd17
Author: Raymond Augé <ro...@apache.org>
Date:   2017-02-08T16:41:26Z

    FELIX-5530 Don't process methods declared on the Annotation class
    
    Signed-off-by: Raymond Augé <ro...@apache.org>

----


> 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)