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

Prevent custom JsonElement subclasses #1689

Closed

Conversation

Marcono1234
Copy link
Collaborator

Adds a package-private constructor to JsonElement to prevent custom subclasses. JsonElement models the JSON data types so there should probably be no need for custom subclasses because the existing JsonElement subclasses cover all of them. Additionally custom subclasses would cause issues during (de-)serialization because the default type adapter does not support them.

However, maybe there are use cases (in unit tests?) where custom subclasses are desired?
Would it be better to only deprecate the public constructor for now?

@inder123
Copy link
Collaborator

Yeah, we didn't envision JsonElement to be subclassed. However, at this point in time, it will be a backward incompatible change, and not worth making.

@inder123 inder123 closed this May 18, 2020
@Marcono1234
Copy link
Collaborator Author

Marcono1234 commented May 19, 2020

Should the public constructor be marked as deprecated at least?

Edit: Nevermind, creating custom subclasses might not actually be that problematic because the default type adapter only calls the JsonElement methods, but does not perform and checks on the class of the object.

@Marcono1234 Marcono1234 deleted the prevent-json-element-subclasses branch May 19, 2020 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants