404-not-find / orika

Automatically exported from code.google.com/p/orika
2 stars 0 forks source link

Unable to map class with self-referencing generics and Comparable return type #161

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The attached testcase fails constructing the mapping factory when mapping a 
class. The class has self referential generics (Foo <T extends Foo<T>>) and 
also a getter that returns an Optional<Range<String>>. The mapping construction 
will fail with the following exception:

Caused by: java.lang.IllegalArgumentException: types Foo and Range<String> are 
not comparable
    at ma.glasnost.orika.metadata.TypeUtil.getMostSpecificType(TypeUtil.java:157)
    at ma.glasnost.orika.metadata.TypeUtil.resolveActualTypeArguments(TypeUtil.java:94)
    at ma.glasnost.orika.metadata.TypeUtil.resolveActualTypeArguments(TypeUtil.java:55)
    at ma.glasnost.orika.metadata.TypeFactory.resolveValueOf(TypeFactory.java:396)
    at ma.glasnost.orika.property.PropertyResolver.resolveGenericType(PropertyResolver.java:174)
    at ma.glasnost.orika.property.PropertyResolver.resolvePropertyType(PropertyResolver.java:312)
    at ma.glasnost.orika.property.PropertyResolver.processProperty(PropertyResolver.java:248)
    at ma.glasnost.orika.property.IntrospectorPropertyResolver.collectProperties(IntrospectorPropertyResolver.java:83)

The Optional<Range<C extends Comparable<C>>> does work without the self 
referential generics, and the self referential generics work as advertised when 
used without the getter returning the Optional<Range<C...>

See the attached test case for the failure.

Original issue reported on code.google.com by martijn....@gmail.com on 8 May 2014 at 1:44

Attachments:

GoogleCodeExporter commented 8 years ago
A fix has been pushed; please try the latest snapshot and let us know how it 
works...

Original comment by matt.deb...@gmail.com on 11 Jun 2014 at 4:42