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

Kryo class resistration through reflection does not take in consideration Interface fields or Parameterized type field #1

Open
L-Applin opened this issue Jun 15, 2020 · 2 comments

Comments

@L-Applin
Copy link
Collaborator

L-Applin commented Jun 15, 2020

It is useless to register interfaces for Kryo, because it is the concrete class that needs to be serialized to transfer over network. Also, there is no easy way to know all specific implementation of a class with a parameterized type. Therefore, the automatic registration of classes for Kyro fails to identify some cases with some dtos. As such interfaces and generics type wont have their resolved type registered automatically.

If we really wish to use 100 % automatic registration, we should find a solution for that.

It is not a big blocker because if we know the resolved type in those case, we can register those classes manually

@payne911
Copy link
Owner

As a reference, see Register and MarvelousBobProperties classes in the common module, for contextual code.

@L-Applin
Copy link
Collaborator Author

L-Applin commented Jun 21, 2020

@payne911 A possible solution could be to add an annotation to interface fields of the dtos, something like @Implementations(classes = {ArrayList.class, LinkedList.class}) or @Register({ArrayList.class, LinkedList.Class}) to specify right at the problematic field location, which implementations of the Interface, or generic field, needs to be Register for that field. It then becomes esay to check for that annotation during registration process and also register classes specified in the annotation argument. Ex:

public final class GameStateDto extends IndexedDto<GameStateDto> implements Timestamped,
        Comparable<GameStateDto> {

    @RegisterImplementations(classes = {ConcurrentHashMap.class});
    private final Map<Integer, PlayerDto> playersDtos;
    private long timestamp;
// ...
}

The exact name of the Annotation would still needs to be determined. Something expressive enough.

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

No branches or pull requests

2 participants