Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
when converting annotations to Maps, don't handle the methods on the Annotation class, similar to how those from Object are ignored.
e.g.
Annotation annotation = (Annotation)...; Map<String, Object> map = c.convert(annotation).sourceAs( annotation.annotationType()).to( 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()) || Annotation.class.equals(md.getDeclaringClass())) return null; // do not use any methods on the Object or Annotation class as a accessor
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.
.sourceAs(annotation.annotationType()).to(...)
Attachments
Issue Links
- links to