Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ClassCastExceptions due to wrong type detection in certain hierarchies. #568

Merged
merged 3 commits into from
Dec 11, 2018

Conversation

michael-simons
Copy link
Collaborator

This PR fixes #492.

Please see the individual commit messages.
In short:

  • Allow for a better detection of field types
  • Use this during computation of FieldInfo: FieldInfo now checks the class hierarchy of a the current class in question and adds the declared fields of the hierarchy when the fields are generically types fields. Thus, the FieldsInfo of the concrete class takes precedence over the base class. this was the root cause, the generic fields would resolve as Object and than the mapper writes collection "as is"
  • Fixes a bug that was probably unrelated, but the elements of arrays needs to be coerced during "our" types as well.

Again, I can take of merging into master and 3.1 if I see green lights. The changes in FieldsInfo and FieldInfo are actual very non-invasive.

The current implementation fails in some scenarios. Including the full type tools seems overkill and as it stands, it has only tested with JDK 9 and still uses Unsafe.

Rewriting GenericTools would look pretty similar for our needs.
Take all declared fields of the hierarchy into consideration when building a FieldsInfo for concrete classes. Resolve type of generics fields in subtype.

This change also includes the tests from the original bug report.
This bug is probably unrelated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generic arrays results in ClassCastException, as the value is actually a Collection
1 participant