-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Deprecate JsonElement constructor #1761
Deprecate JsonElement constructor #1761
Conversation
Creating custom JsonElement subclasses is discouraged.
@eamonnmcmanus, could you please have a look? |
Thanks! I agree with the principle. I had a couple of small comments. |
reader.peek(); | ||
fail(); | ||
} catch (MalformedJsonException expected) { | ||
assertEquals("Custom JsonElement subclass com.google.gson.internal.bind.JsonTreeReaderTest$1CustomSubclass is not supported", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would write:
assertEquals("Custom JsonElement subclass " + CustomSubclass.class.getName() + " is not supported", ...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, that hardcoded generated name JsonTreeReaderTest$1CustomSubclass
would likely cause problems in the future.
Experimentally, I tried just changing the |
To be safe, I think keeping the constructor for now might be better because at least the Auto.js project has a custom subclass. Also, unlike some other issues, keeping the deprecated |
OK, given that we know of one subclass I agree that the change here is the right way to go. |
Follow-up for #1689.
Creating custom JsonElement subclasses is discouraged and will lead to issues when using JsonTreeReader.