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 Auge <ra...@liferay.com> on 2017/02/07 18:04:57 UTC

[converter]

Hello DavidB,

I'm using the converter in the CDI work I'm doing and I'm noting a strange
behaviour in converting Annotations (qualifiers) to Maps. Basically it
looks like the converter is following all methods of the annotation type,
rather than only the declared method:

In other words, if I start with an Annotation like so:

    public @interface ComplexEnoughKey {
        String value();
    }

used as:

@ComplexEnoughKey("fum")

Using the converter like so:

Map<String, String> map = _converter.convert(annotation).to(new
TypeReference<Map<String, String>>(){});

I'm getting a map like this:

{hashCode=1335732849, annotationType=interface
org.apache.aries.cdi.test.beans.BeanWithReference$ComplexEnoughKey,
toString=@org.apache.aries.cdi.test.beans.BeanWithReference$ComplexEnoughKey(value=fum),
value=fum}

I was expecting:

{value=fum}

Shouldn't annotations only use the
annotation.annotationType().getDeclaredMethods()?

Also, I don't see any name mangling happening. I thought that was part of
the standard rules.

Do I chalk all this up to "work in progress"? If so I can send some PRs
with fixes for the above.

Sincerely,
- Ray

Re: [converter]

Posted by David Bosschaert <da...@gmail.com>.
Hi Ray,

You are right that this is still WIP to a certain degree.
And I think your expectation is correct, so it would be great if you could
provide some fixes for these!

Cheers,

David

On 7 February 2017 at 10:04, Raymond Auge <ra...@liferay.com> wrote:

> Hello DavidB,
>
> I'm using the converter in the CDI work I'm doing and I'm noting a strange
> behaviour in converting Annotations (qualifiers) to Maps. Basically it
> looks like the converter is following all methods of the annotation type,
> rather than only the declared method:
>
> In other words, if I start with an Annotation like so:
>
>     public @interface ComplexEnoughKey {
>         String value();
>     }
>
> used as:
>
> @ComplexEnoughKey("fum")
>
> Using the converter like so:
>
> Map<String, String> map = _converter.convert(annotation).to(new
> TypeReference<Map<String, String>>(){});
>
> I'm getting a map like this:
>
> {hashCode=1335732849, annotationType=interface
> org.apache.aries.cdi.test.beans.BeanWithReference$ComplexEnoughKey,
> toString=@org.apache.aries.cdi.test.beans.BeanWithReference$
> ComplexEnoughKey(value=fum),
> value=fum}
>
> I was expecting:
>
> {value=fum}
>
> Shouldn't annotations only use the
> annotation.annotationType().getDeclaredMethods()?
>
> Also, I don't see any name mangling happening. I thought that was part of
> the standard rules.
>
> Do I chalk all this up to "work in progress"? If so I can send some PRs
> with fixes for the above.
>
> Sincerely,
> - Ray
>