CodeMD repository analysis · example report
An analysis of github.com/google/gson as it was on 2026-11-13.
What the repository is and how it is built, written by AI from the analysis.
Gson is a Java library from Google for converting Java objects into their JSON representation and converting JSON strings back into equivalent Java objects. It can work with arbitrary Java objects, including pre-existing ones whose source code you don't have. Unlike many JSON libraries, it doesn't require annotations in your classes, and it fully supports Java Generics.
Gson is in maintenance mode: existing bugs will be fixed, but large new features are unlikely. It is focused on Java. Other JVM languages such as Kotlin or Scala may work, but language-specific features aren't supported. It is also not recommended for Android, because its reflection-based runtime conflicts with shrinking, optimization and obfuscation.
toJson() turns objects into JSON and fromJson() turns JSON into objects.java.sql module is present.Unsafe when it is available, and this can be disabled.com.google.gson) is included for Java 9+.proto module provides a JSON serializer and deserializer for Protocol Buffers messages. It isn't deployed to Maven Central.proto module.Gson is a multi-module Maven project:
gson: The core library, published to Maven Central as com.google.code.gson:gson.extras: Supplementary features that aren't included by default. Not deployed to Maven Central.proto: The Protocol Buffers JSON serializer and deserializer. Not deployed to Maven Central.metrics: Internal benchmark tests.test-graal-native-image: Integration tests for GraalVM Native Image, including reflection metadata. These are not enabled by default.test-jpms: Tests that verify the module descriptor against the final JAR.test-shrinker: Integration tests with code shrinking and obfuscation tools such as ProGuard and R8.Gson 2.12.0 and newer require Java 8. The java.sql and jdk.unsupported JDK modules are optional dependencies. Building requires JDK 17 or newer, and JDK 21 is recommended. Gson is released under the Apache 2.0 license.
12 features found in the code and documentation.
Converts Java objects into their JSON representation with a simple toJson() call.
Converts JSON strings into equivalent Java objects with a simple fromJson() call.
Converts pre-existing, unmodifiable objects to and from JSON without requiring annotations or access to their source code.
Fully handles generic types so parameterized classes can be serialized and deserialized correctly.
Lets you define custom JSON representations for objects via type adapters instead of the default mapping.
Supports arbitrarily complex objects, including deep inheritance hierarchies and heavy use of generic types.
Serializes and deserializes Java records.
Provides built-in adapters for SQL date and time classes when the java.sql module is present.
Can create instances of classes lacking a no-args constructor using Unsafe when available, with an option to disable it.
Ships a JPMS module descriptor (com.google.gson) so Java 9+ projects can use it as a named module.
An optional proto module offers a JSON serializer and deserializer for Protocol Buffers messages.
Includes ProGuard/R8 guidance and tests plus GraalVM Native Image tests to support shrunken and native builds.
Possible problems found without running the code.
| Kind | Signal | Where | Severity |
|---|---|---|---|
| Structure | Function has no callers in the callgraph `RawCollectionsExample.main` is parsed as code and calls 1 function(s), but no parsed code calls it. | extras/src/main/java/com/google/gson/extras/examples/rawcollections/RawCollectionsExample.java:41 | medium |
| Structure | Function has no callers in the callgraph `RuntimeTypeAdapterFactory.recognizeSubtypes` is parsed as code and calls 1 function(s), but no parsed code calls it. | extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java:206 | medium |
| Structure | Function has no callers in the callgraph `RuntimeTypeAdapterFactory.create` is parsed as code and calls 1 function(s), but no parsed code calls it. | extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java:243 | medium |
| Structure | Function has no callers in the callgraph `RuntimeTypeAdapterFactory.read` is parsed as code and calls 7 function(s), but no parsed code calls it. | extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java:265 | medium |
| Structure | Function has no callers in the callgraph `RuntimeTypeAdapterFactory.write` is parsed as code and calls 7 function(s), but no parsed code calls it. | extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java:296 | medium |
| Structure | Function has no callers in the callgraph `UtcDateTypeAdapter.write` is parsed as code and calls 1 function(s), but no parsed code calls it. | extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java:36 | medium |
| Structure | Function has no callers in the callgraph `UtcDateTypeAdapter.read` is parsed as code and calls 1 function(s), but no parsed code calls it. | extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java:46 | medium |
| Structure | Function has no callers in the callgraph `InterceptorTest.setUp` is parsed as code and calls 1 function(s), but no parsed code calls it. | extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java:47 | medium |
| Call graph | Function calls itself `com_google_gson_TypeAdapter_NullSafeTypeAdapter_read_java_lang_Object_com_google_gson_stream_JsonReader_` has a direct self-call in the static callgraph. | | medium |
| Call graph | Function calls itself `com_google_gson_TypeAdapter_NullSafeTypeAdapter_write_void_com_google_gson_stream_JsonWriter_java_lang_Object_` has a direct self-call in the static callgraph. | | medium |
| Call graph | Function calls itself `com_google_gson_internal_GsonTypes_canonicalize_java_lang_reflect_Type_java_lang_reflect_Type_` has a direct self-call in the static callgraph. | | medium |
| Call graph | Function calls itself `com_google_gson_internal_GsonTypes_equals_boolean_java_lang_reflect_Type_java_lang_reflect_Type_` has a direct self-call in the static callgraph. | | medium |
| Call graph | Function calls itself `com_google_gson_internal_GsonTypes_getGenericSupertype_java_lang_reflect_Type_java_lang_reflect_Type_java_lang_Class_java_lang_Class_` has a direct self-call in the static callgraph. | | medium |
| Call graph | Function calls itself `com_google_gson_internal_GsonTypes_getRawType_java_lang_Class_java_lang_reflect_Type_` has a direct self-call in the static callgraph. | | medium |
| Call graph | Function calls itself `com_google_gson_internal_GsonTypes_resolve_java_lang_reflect_Type_java_lang_reflect_Type_java_lang_Class_java_lang_reflect_Type_java_util_Map_` has a direct self-call in the static callgraph. | | medium |
| Call graph | Function calls itself `com_google_gson_internal_LinkedTreeMap_removeInternal_void_com_google_gson_internal_LinkedTreeMap_Node_boolean_` has a direct self-call in the static callgraph. | | medium |
A sample of the highest-ranked signals. These come from static analysis: they are leads to review, not confirmed bugs.
Functions nothing in the repository calls.
4 functions have no caller in the call graph. They may be public API, called dynamically, or dead code.
| Function | Location | Lines |
|---|---|---|
C.C | gson/src/test/java/com/google/gson/functional/JsonAdapterAnnotationOnClassesTest.java:245 | 5 |
RuntimeTypeAdapterFactoryFunctionalTest.of | gson/src/test/java/com/google/gson/functional/RuntimeTypeAdapterFactoryFunctionalTest.java:114 | 9 |
RuntimeTypeAdapterFactoryFunctionalTest.of | gson/src/test/java/com/google/gson/functional/RuntimeTypeAdapterFactoryFunctionalTest.java:122 | 9 |
MyClass.MyClass | gson/src/test/java/com/google/gson/functional/SerializedNameTest.java:58 | 6 |
What changed in the last 30 days, in plain language.
Gson daily change summary (google/gson, 19 commits by 5 authors in the window; the payload shows details for the first four commits and part of the fifth, so this covers only those)
1. Standardizing the project name to "Gson" (881d2b5, Marcono1234, #3150)
Gson.java.Gson.getAdapter now throws IllegalArgumentException("Gson (<version>) cannot handle <type>").Gson.getDelegateAdapter now throws "Gson cannot serialize or deserialize <type>".AssertionError wrappers in Gson.toJson (two overloads) and Gson.fromJson now read "AssertionError (Gson <version>): ...".GsonVersionDiagnosticsTest was updated to match: its regex is now \(Gson \d\.\d+\.\d...\), and the sample strings and the indexOf("(Gson") check were changed too.RuntimeTypeAdapterFactoryMapTypeAdapterFactoryStreams (now says "JsonElement trees")TypeAdapters (a comment about compatibility with Gson 1.7)ProtoTypeAdapterFieldExclusionTestGson.java. Every changed function is labelled low risk, and the only behavioral change is the message text.2. Comment typo fix (094f500, Marcono1234, #3148)
Gson.fromJson and Streams.parse.Streams.parse is flagged high risk (47 impacted callers across 12 files) only because of how widely it is used.3. Build and tooling changes (Éamonn McManus)
pom.xml, the disable-spotless profile now applies to JDKs before 21 instead of before 17. The Spotless formatting plugin therefore only runs on Java 21 or later.proto/pom.xml, protobuf-maven-plugin went from 5.1.8 to 5.1.11.4. Release 2.15.0 (fcd4169, Éamonn McManus, maven-release-plugin)
README.md and UserGuide.md now show 2.15.0 in the Gradle and Maven snippets, replacing 2.14.0.extras/pom.xml moves from 2.14.1-SNAPSHOT to 2.15.0, including the parent and the gson dependency. Its reproducible-build timestamp is now 2026-10-24T01:05:45Z, and its SCM tag is gson-parent-2.15.0.gson/pom.xml has parent-version edits that were cut off in the payload.Overall: Gson 2.15.0 was prepared for release on 2026-10-24. The code changes in the window are the "Gson" naming cleanup, which also changes some exception message text, and one comment typo fix. The rest is build maintenance: the Spotless JDK threshold, a protobuf plugin bump and the release version changes.
An example question, answered from the code.
What does this project do and how is it organised?
The user asks what this project does and how the repository is organised.
pom.xml, gson/pom.xml, extras/pom.xml and test-shrinker/pom.xml all appear in the evidence.gson/src/main/java/com/google/gson/, for example internal/GsonTypes.java. Its tests live under gson/src/test/java/com/google/gson/, with functional tests in a functional/ subfolder.proto/ and test-graal-native-image/ modules. The supplied source evidence does not show these directly, so treat them as unconfirmed.What it does
JsonPrimitiveTest (gson/src/test/java/com/google/gson/JsonPrimitiveTest.java) checks JsonPrimitive equality and hash codes across number types. testEqualsAcrossTypes shows that JsonPrimitive("a") equals JsonPrimitive('a'), and that the numeric types BigInteger, int, long, BigDecimal and Float.NaN/Double.NaN compare equal across types. testEqualsDoesNotEquateStringAndNonStringTypes shows that JsonPrimitive("true"), "0" and "NaN" do not equal the boolean, integer and float primitives.ExclusionStrategyFunctionalTest covers exclusion strategies.CustomTypeAdaptersTest and GsonTypeAdapterTest cover custom type adapters.MixedStreamTest has tests named testReadDoesNotMutateState and testWriteDoesNotMutateState.ReflectionAccessFilterTest includes the message "ReflectionAccessFilter does not permit using reflection for class java.io.Reader".GsonTypes.newParameterizedTypeWithOwner (gson/src/main/java/com/google/gson/internal/GsonTypes.java:48-59) is the one production function shown. Its callers are GsonTypes.resolve, TypeToken.getParameterized, and several tests (GenericArrayTypeTest.setUp, GsonTypesTest.*, MapTest.testCustomSerializerForSpecificMapType, ParameterizedTypeTest.setUp). The graph shows no callees, and the function body is not included. Its callers are consistent with the generics support described in README.md:6.How it is organised
pom.xml at the root and a pom.xml in each of gson/, extras/ and test-shrinker/. A comment in test-shrinker/pom.xml:157 says R8 runs as a standalone JAR and doesn't need any of the project classes.README.md and UserGuide.md sit at the root.gson/, production code is under src/main/java/com/google/gson/ (with an internal package), and tests are under src/test/java/com/google/gson/.extras/ as supplementary features and test-shrinker/ as shrinker tests (R8/ProGuard). They also describe the core classes Gson, GsonBuilder, JsonElement, JsonPrimitive, TypeToken, JsonReader and JsonWriter. Treat these as derived context. Only JsonPrimitive, TypeToken and GsonTypes are corroborated by the source snippets.Gaps
Gson or GsonBuilder source, or the module list from the root pom.xml. Module responsibilities beyond gson/ are therefore not directly confirmed.An AI review of how outside input reaches risky operations.
No exploitable findings.
This repository is Gson, a JSON serialization library. It has no network service, no authentication, no agent or tool execution, no handling of credentials, and no file-system operations that take paths from JSON input. Its only entry points are benchmark and example main() methods. I checked the flagged sinks and none of them can be driven by untrusted input. (1) Every Class.forName call in main code uses a hard-coded literal: sun.misc.Unsafe, java.lang.reflect.RecordComponent, java.sql.Date and com.google.gson.internal.bind.JavaTimeTypeAdapters. JSON data never chooses which class gets loaded. (2) Deserialization picks its target type from the developer-supplied Type/TypeToken, not from the JSON. Polymorphic deserialization in extras (RuntimeTypeAdapterFactory.create/read) looks the type label up in the developer-registered labelToDelegate map and throws JsonParseException for unknown labels, so it is an allowlist and cannot be used as a gadget chain. (3) LazilyParsedNumber.readObject and LinkedTreeMap.readObject are Java-serialization guards that throw InvalidObjectException. They are not sinks. (4) The 'file write/delete' and 'network' matches (JsonArray.remove, LinkedTreeMap.remove, JsonTreeWriter.endArray, TypeAdapters.read) are false positives: they only change in-memory collections or JSON trees. UnsafeAllocator does build objects without calling a constructor, but only for the type the application asked for, and ReflectionAccessFilter can limit it. That is an application-level design choice, not a path to code execution, file access or credential theft. No attack chain meets the catastrophic threshold.