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 object mapping interface/abstract field types #91

Merged
merged 2 commits into from
Apr 28, 2018

Conversation

dags-
Copy link
Contributor

@dags- dags- commented Mar 8, 2018

For interface/abstract classes, the TypeSerializer currently adds a __class__ node whose value is the canonical name of the interface/abstract class. This isn't very useful when it comes to deserialization since we want to know the concrete type in order to instantiate and populate.

This PR changes the behaviour so that, during serialization, it's the instance's class that is used in the __class__ node instead (which I believe was the original intention).

- Serialize the instance's type rather than the interface/abstract type (which I believe was the intention).
- Check that deserialized classes are children of the TypeSerializer's raw type.
- Replace 'Class.getCanonicalName' with 'Class.getName' which returns the correct string for calls to 'Class.forName'.
- Added interface serialization test to ObjectMapperTest
@dags- dags- changed the title Fix serialization of interface/abstract types Fix object mapping interface/abstract field types Mar 8, 2018
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no star imports

@kashike kashike self-assigned this Apr 28, 2018
@kashike kashike merged commit c99a39c into SpongePowered:master Apr 28, 2018
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.

3 participants