PR #2139 changed this factory so that if given a certain baseType, it will also
recognize any subtype of that type. That is often the right thing to do, but it
is a change in behaviour, and does in fact break at least one current client of
this code. So instead we introduce a new `recognizeSubclasses()` method that
triggers this behaviour. When the method is not called, we revert to the old
behaviour of only recognizing instances of the exact class `baseType`.
* Change the RuntimeTypeAdapterFactoryTest, so it fails because of #712
* Fix RuntimeTypeAdapterFactory
Trying to use this class as is results in the type-property not being serialized into the JSON, thus it is not present on deserialization.
The fix from https://github.com/google/gson/issues/712#issuecomment-148955110 works. No idea why this is not merged yet.
* Add support for reflection access filter
* Improve documentation
* Fix compilation errors
* Relax handling for BLOCK_ALL when invoking default constructor
* Improve handling for inherited fields
* Fix accessible test failing for static fields
* Simplify ReflectiveTypeAdapterFactory field writing
* Fix GsonBuilder changes affecting created Gson instances
* Improve documentation
* Improve handling for IllegalAccessException
For Java < 9, AccessibleObject.canAccess is not available and therefore checks
might pass even if object is not accessible, causing IllegalAccessException
later.
* Fix incorrect GsonBuilder.addReflectionAccessFilter documentation
* Add CodeQL GitHub code scanning workflow
* Only compile main sources for code scanning
* Move test .proto files to test sources
`annotations.proto` also seems to be only relevant for tests because the test
explicitly registers them as extensions. By default the Proto adapter does not
consider them.
* Address some code scanning findings
* Fix some more findings
* Fix RuntimeTypeAdapterFactory depending on internal Streams class
* Clean up gson-extras project, make it Maven module of gson-parent
* Remove broken test from GraphAdapterBuilderTest
When we maintain the label value, we do not need to make a new JsonObject and copy over the keys and values when writing. The ordering will change, though. Before this change, it always put the label first.
* Avoid NPE in PostConstructAdapterFactory
The RawType's Superclass might be null. This happens, for example, when the type is a collection.
* Add test case for NPE in PostConstructAdapterFactory
* Improve the code quality of PostConstructAdapterFactoryTest
* Improve the code quality of PostConstructAdapterFactoryTest
* Improve the code quality of PostConstructAdapterFactoryTest
Instances of classes that implement RuntimeTypeAdapterFactory should be registered using the registerTypeAdapterFactory method instead of registerTypeAdapter.
Serialize graphs of objects by assigning each instance a generated ID and writing the complete graph out as a list. The output for a cycle of Rock/Scissors/Paper looks like this:
{
'0x1':{'name':'ROCK','beats':'0x2'},
'0x2':{'name':'SCISSORS','beats':'0x3'},
'0x3':{'name':'PAPER','beats':'0x1'}
}
This is work towards issue 137. The hard part is going to be deserializing that back into a graph.