You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks to #439, there is base generic type support for fields. But there are cases still not covered: e.g. if the generic type is inherited. The given test shows an issue:
java.lang.ClassCastException: class org.jeasy.random.GenericComplicatedTest$SubLongResource cannot be cast to class java.lang.Long (org.jeasy.random.GenericComplicatedTest$SubLongResource is in unnamed module of loader 'app'; java.lang.Long is in module java.base of loader 'bootstrap')
at org.jeasy.random.GenericComplicatedTest.genericInheritedShouldBeCorrectlyPopulated(GenericComplicatedTest.java:42)
The text was updated successfully, but these errors were encountered:
seregamorph
changed the title
Incomplete generic field type support
Generic field type issue (inheritance)
Nov 9, 2020
Thank you for reporting this. Indeed, ER seems to resolve K as SubLongResource instead of Long. As mentioned in #425 (comment) , I'm not expecting ER to support this kind of use cases out of the box, that's why I updated the known limitations section accordingly when I released 4.3:
Due to type erasure, there are some cases where Easy Random is not able to get the information required
about a class or a field type at runtime.
Your use case is clearly one of them. That said, I will try to see if we can improve things in the next iteration (at least try to correctly detect unsupported cases and throw an exception with a clear message about that).
Thanks to #439, there is base generic type support for fields. But there are cases still not covered: e.g. if the generic type is inherited. The given test shows an issue:
Fails with message:
The text was updated successfully, but these errors were encountered: