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

Need an annotation to denote proper field ordering #3

Open
creativedrewy opened this issue Jul 5, 2021 · 1 comment
Open

Need an annotation to denote proper field ordering #3

creativedrewy opened this issue Jul 5, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@creativedrewy
Copy link

As I've come to learn with Borsh serialization, the processing order of the fields is of utmost importance for proper serialization/deserialization. Unfortunately Java doesn't enforce any sort of internal ordering for its properties, so when borshj goes to deserialize, the properties might be handled in any order, thus making deserialization not work.

As a result, an annotation with an order property is likely needed for POJO fields to denote the order that they should be handled. Then when processing the fields in the readPOJO() methods, you can just sort by the annotation's order number and things will work properly. I've submitted a PR with just such an annotation for a kotlin-based implementation of borsh. You can see it here:

metaplex-foundation/SolanaKT#31

@artob
Copy link
Contributor

artob commented Dec 9, 2021

This would be a good feature to have. Pull requests welcome!

@artob artob removed their assignment Dec 9, 2021
@artob artob added the enhancement New feature or request label Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants