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

JSON: Cannot override default class information #5

Open
comick opened this issue Apr 28, 2018 · 2 comments
Open

JSON: Cannot override default class information #5

comick opened this issue Apr 28, 2018 · 2 comments

Comments

@comick
Copy link
Contributor

comick commented Apr 28, 2018

When JSON serializer is used to serialize a class that comes as bytecode only is not possible to put annotations on it: defaults from ClassInformation are applied for visibility.

Could having configurable defaults defined in JsonSerializerContext or a user configurable ClassInformationProvider be a reasonable solution?

@konsoletyper
Copy link
Owner

This is impossible to have configurable defaults since all serializers and deserializers are generated in compile time, and thus all rules applied and resolved during compile time.

You can annotations to the classes by instrumentation. You can use either javaagent + ASM which is standard for JVM, or write a TeaVM plugin and add ClassHolderTransformer from there. Note that when you implement your own plugin (i.e. implement TeaVMPlugin interface), you should apply service loader convention (i.e. META-INF/services).

Another solution would be to add ability to add compiler plugins to Flavour that can customize default rules.

@comick
Copy link
Contributor Author

comick commented Feb 3, 2019

I solved the problem by using a TeaVM plugin on top of #17.

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