Repository navigation
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.
I think I would write:
assertEquals("Custom JsonElement subclass " + CustomSubclass.class.getName() + " is not supported", ...)
There was a problem hiding this comment.
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.