Commit Graph

1445 Commits

Author SHA1 Message Date
Marcono1234 a45c55739f
Improve ArrayTypeAdapter for Object[] (#1716)
* Improve ArrayTypeAdapter for Object[]

* Fix typo in test method names
2022-07-31 14:49:02 -07:00
Marcono1234 5f2513a407
Improve AppendableWriter performance (#1706)
* Improve AppendableWriter performance

Override methods which by default create char arrays or convert
CharSequences to Strings.
This is not necessary for AppendableWriter because it can directly
append these values to the Appendable delegate.

* Add test for Streams.writerForAppendable
2022-07-31 14:46:43 -07:00
Éamonn McManus ca22b68008 [maven-release-plugin] prepare for next development iteration 2022-07-31 14:25:34 -07:00
Éamonn McManus bb9a1f255a [maven-release-plugin] prepare release gson-parent-2.9.1 2022-07-31 14:25:32 -07:00
Marcono1234 893a7e1c5c
Fix malformed JsonElement.getAsBigDecimal() javadoc (#1772) 2022-07-31 14:08:24 -07:00
Marcono1234 6d2557d5d1
Remove unused package-private FieldAttributes methods (#2162) 2022-07-29 10:10:54 -07:00
dependabot[bot] 924c496b95
Bump maven-resources-plugin from 3.2.0 to 3.3.0 (#2157)
Bumps [maven-resources-plugin](https://github.com/apache/maven-resources-plugin) from 3.2.0 to 3.3.0.
- [Release notes](https://github.com/apache/maven-resources-plugin/releases)
- [Commits](https://github.com/apache/maven-resources-plugin/compare/maven-resources-plugin-3.2.0...maven-resources-plugin-3.3.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-resources-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-25 20:37:16 -07:00
Marcono1234 503c20bb39
Rename ReflectiveTypeAdapterFactory field inclusion check method (#2121) 2022-07-21 11:53:52 -07:00
Marcono1234 cbc0af867b
Improve lenient mode documentation (#2122) 2022-06-28 09:48:05 -07:00
Marcono1234 2d01d6a20f
Make `Object` and `JsonElement` deserialization iterative (#1912)
* Make Object and JsonElement deserialization iterative

Often when Object and JsonElement are deserialized the format of the JSON
data is unknown and it might come from an untrusted source. To avoid a
StackOverflowError from maliciously crafted JSON, deserialize Object and
JsonElement iteratively instead of recursively.

Concept based on 51fd2faab7
But implementation is not based on it.

* Improve imports grouping

* Address review feedback
2022-06-22 17:42:19 -07:00
Nathan Herring d2aee6502b
Add explicit support for floats in JsonTreeWriter. (#2132)
Follow-up to comments on #2130, which introduced a new override which was not overridden by `JsonTreeWriter`. Also tweaks the doccomments for `float`, `double` and `Number` variants of `JsonWriter.value`.

Supplement to the fix for #1127.
2022-06-21 09:50:07 -07:00
dependabot[bot] 08d4572fc4
Bump proguard-maven-plugin from 2.5.3 to 2.6.0 (#2136)
Bumps [proguard-maven-plugin](https://github.com/wvengen/proguard-maven-plugin) from 2.5.3 to 2.6.0.
- [Release notes](https://github.com/wvengen/proguard-maven-plugin/releases)
- [Changelog](https://github.com/wvengen/proguard-maven-plugin/blob/master/CHANGELOG.md)
- [Commits](https://github.com/wvengen/proguard-maven-plugin/commits)

---
updated-dependencies:
- dependency-name: com.github.wvengen:proguard-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-20 17:01:20 -07:00
Marcono1234 57225c6741
Fail when parsing invalid local date (#2134)
* Fail when parsing invalid local date

* Improve invalid date tests
2022-06-16 13:47:57 -07:00
Nathan Herring 96ab171eb4
Add explicit support for floats in JsonWriter. (#2130)
This avoids floats being treated as doubles and having an unwarranted level of precision.

Fixes #1127.
2022-06-08 15:04:42 -07:00
dependabot[bot] 15b9fa9c31
Bump maven-surefire-plugin from 3.0.0-M6 to 3.0.0-M7 (#2128)
Bumps [maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.0.0-M6 to 3.0.0-M7.
- [Release notes](https://github.com/apache/maven-surefire/releases)
- [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.0.0-M6...surefire-3.0.0-M7)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-surefire-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-08 07:21:23 -07:00
dependabot[bot] d1fce29b27
Bump bnd-maven-plugin from 6.2.0 to 6.3.1 (#2129)
Bumps [bnd-maven-plugin](https://github.com/bndtools/bnd) from 6.2.0 to 6.3.1.
- [Release notes](https://github.com/bndtools/bnd/releases)
- [Changelog](https://github.com/bndtools/bnd/blob/master/docs/ADDING_RELEASE_DOCS.md)
- [Commits](https://github.com/bndtools/bnd/compare/6.2.0...6.3.1)

---
updated-dependencies:
- dependency-name: biz.aQute.bnd:bnd-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-08 07:21:02 -07:00
Johannes Frohnmeyer 379b2563b2
Use deferred comment serialization to fix prominent issues 2022-06-04 11:59:48 +02:00
Johannes Frohnmeyer 031f729d32
Fix Json5 test 2022-05-17 21:40:18 +02:00
Johannes Frohnmeyer 41cafc0987
Remove references to deleted test 2022-05-17 21:35:52 +02:00
Johannes Frohnmeyer dc4e61ac7b
Several breaking changes 2022-05-17 21:20:10 +02:00
Johannes Frohnmeyer ccf30b23e8 newline before comment 2022-05-17 06:15:12 +00:00
Johannes Frohnmeyer 35241fc7b2
Add comment support 2022-05-12 23:23:14 +02:00
Johannes Frohnmeyer 9d7fd891ee
Merge branch 'allow_duplicate_map_key'
# Conflicts:
#	gson/src/main/java/com/google/gson/GsonBuilder.java
#	gson/src/test/java/com/google/gson/GsonTest.java
2022-05-12 22:54:17 +02:00
Marcono1234 b1c399fd62
Improve `TypeToken` creation validation (#2072)
* Add comments regarding multiple bounds of wildcard

* Remove WildcardType check in getCollectionElementType

The returned Type is never a wildcard due to the changes made to getSupertype
by commit b1fb9ca9a1.

* Remove redundant getRawType call from MapTypeAdapterFactory

getRawType(TypeToken.getType()) is the same as calling TypeToken.getRawType().

* Make TypeToken members private

* Remove incorrect statement about TypeToken wildcards

It is possible to use wildcards as part of the type argument, e.g.:
`new TypeToken<List<? extends CharSequence>>() {}`

* Only allow direct subclasses of TypeToken

Previously subclasses of subclasses (...) of TypeToken were allowed which
can behave incorrectly when retrieving the type argument, e.g.:

  class SubTypeToken<T> extends TypeToken<Integer> {}
  new SubTypeToken<String>() {}.getType()

This returned `String` despite the class extending TypeToken<Integer>.

* Throw exception when TypeToken captures type variable

Due to type erasure the runtime type argument for a type variable is not
available. Therefore there is no point in capturing a type variable and it
might even give a false sense of type-safety.

* Make $Gson$Types members private

* Rename $Gson$Types.getGenericSupertype parameter

Rename the method parameter to match the documentation of the method and
to be similar to getSupertype(...).

* Improve tests and handle raw TypeToken supertype better

* Make some $Gson$Types members package-private again to prevent synthetic accessors

* Remove TypeToken check for type variable

As mentioned in review comments, there are cases during serialization where
usage of the type variable is not so problematic (but still not ideal).
2022-04-19 08:20:58 -07:00
Marcono1234 4dda4ec5ba
Use diamond operator when creating generic instances (#2104) 2022-04-17 15:27:21 -07:00
Marcono1234 e82637c485
Add support for reflection access filter (#1905)
* 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
2022-04-17 09:05:18 -07:00
dependabot[bot] f79ea208b1
Bump maven-surefire-plugin from 3.0.0-M5 to 3.0.0-M6 (#2101)
Bumps [maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.0.0-M5 to 3.0.0-M6.
- [Release notes](https://github.com/apache/maven-surefire/releases)
- [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.0.0-M5...surefire-3.0.0-M6)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-surefire-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-03 20:08:33 -07:00
dependabot[bot] 9125653278
Bump bnd-maven-plugin from 6.1.0 to 6.2.0 (#2084)
Bumps [bnd-maven-plugin](https://github.com/bndtools/bnd) from 6.1.0 to 6.2.0.
- [Release notes](https://github.com/bndtools/bnd/releases)
- [Changelog](https://github.com/bndtools/bnd/blob/master/docs/ADDING_RELEASE_DOCS.md)
- [Commits](https://github.com/bndtools/bnd/compare/6.1.0...6.2.0)

---
updated-dependencies:
- dependency-name: biz.aQute.bnd:bnd-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-28 07:40:22 -08:00
Marcono1234 81bb6d1dec
Remove `gson/build.gradle` (#2081)
Follow-up for be0a1f4ff7
2022-02-23 11:18:56 -08:00
Marcono1234 b5343ba96c
Add tests for enum constant toString() reading (#2080) 2022-02-21 14:53:59 -08:00
Mahmut H. Kocas 7ee3e2787f
Parsing Map<Enum,Obj> - 501 (#1950)
* Added parsing support for enum that has overridden toString() method.

* Fix a tiny formatting problem

* Fixed formatting issue

Co-authored-by: Éamonn McManus <emcmanus@google.com>
2022-02-21 13:11:43 -08:00
Marcono1234 49ddab9eeb
Add CodeQL GitHub code scanning workflow (#2076)
* 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
2022-02-17 18:40:40 -08:00
Marcono1234 d19e9fe0af
Improve Maven build and GitHub Maven workflow (#2079)
* Fix consecutive Maven builds failing without performing `clean`

By default moditect-maven-plugin refuses to overwrite the JAR file it
generated in a previous run.

* Make GitHub Maven build workflow detect Javadoc issues
2022-02-16 12:51:08 -08:00
Éamonn McManus e58db43f57 [maven-release-plugin] prepare for next development iteration 2022-02-11 11:13:24 -08:00
Éamonn McManus b6acf1178a [maven-release-plugin] prepare release gson-parent-2.9.0 2022-02-11 11:13:22 -08:00
Marcono1234 47dea2eefc
Improve error message when abstract class cannot be constructed (#1814) 2022-02-04 14:19:47 -08:00
Marcono1234 565b7a198e
Support EnumMap deserialization (#2071) 2022-02-04 07:20:32 -08:00
Marcono1234 e2e851c9bc
Add LazilyParsedNumber default adapter (#2060)
* Add LazilyParsedNumber default adapter

* Validate JsonWriter.value(Number) argument

* Fix incorrect JSON number pattern, extend tests
2022-01-28 11:26:28 -08:00
Marcono1234 710a76c8b8
Fix JsonReader.hasNext() returning true at end of document (#2061) 2022-01-27 15:59:50 -08:00
Éamonn McManus 26e08fe742
Fix a mistaken use of StringBuilder('#'). (#2052) 2022-01-12 08:58:30 -08:00
Marcono1234 73216b2ad7
Add more `Gson` default constants to be used by `GsonBuilder` (#2051) 2022-01-12 07:07:55 -08:00
Marcono1234 d38e397421
Fix ObjectTest not restoring default Locale (#2050) 2022-01-10 07:18:42 -08:00
Marcono1234 6b96a389cc
Put `module-info.class` into Multi-Release JAR folder (#2013)
* Put module-info.class into Multi-Release JAR folder

Uses ModiTect to place module-info.class under Multi-Release JAR folder
`META-INF/versions/9`.

* Adjust pom.xml to drop support for Java 6

* Change doclint setting

All Javadoc errors have been solved previously; doclint can now be enabled
without causing build failures.

* Improve README Java requirements
2022-01-01 12:44:39 -08:00
Marcono1234 dc28951fa7
Change target Java version to 7 (#2043)
* Change target Java version to 7

* Document Gson requirements

* Add package-info.java for `stream` package
2021-12-31 07:20:29 -08:00
Marcono1234 615c8835d3
Add `GsonBuilder.disableJdkUnsafe()` (#1904)
* Add GsonBuilder.disableJdkUnsafe()

* Address review feedback
2021-12-30 15:08:18 -08:00
Marcono1234 97938283a7
Remove explicit ProGuard plugin dependencies (#2041)
Explicitly specifying dependencies only seems to be necessary when using
`<proguardVersion>` config element to override version (and even that might
not be necessary; only adding explicit dependencies might suffice). However,
when omitting it, plugin uses a recent ProGuard version on its own.
2021-12-28 09:56:49 -08:00
Marcono1234 abd2191b0e
Add READMEs to Maven modules (#2039)
* Add READMEs to Maven modules

* Address feedback
2021-12-27 10:17:41 -08:00
Marcono1234 6ffcdf3029
Fix Javadoc warnings and errors (#2040) 2021-12-26 15:30:21 -08:00
dependabot[bot] 1dd150e86f
Bump proguard-maven-plugin from 2.5.2 to 2.5.3 (#2037)
Bumps [proguard-maven-plugin](https://github.com/wvengen/proguard-maven-plugin) from 2.5.2 to 2.5.3.
- [Release notes](https://github.com/wvengen/proguard-maven-plugin/releases)
- [Changelog](https://github.com/wvengen/proguard-maven-plugin/blob/master/CHANGELOG.md)
- [Commits](https://github.com/wvengen/proguard-maven-plugin/commits)

---
updated-dependencies:
- dependency-name: com.github.wvengen:proguard-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-12-20 09:37:56 -08:00
dependabot[bot] 4b3127f669
Bump proguard-maven-plugin from 2.5.1 to 2.5.2 (#2034)
Bumps [proguard-maven-plugin](https://github.com/wvengen/proguard-maven-plugin) from 2.5.1 to 2.5.2.
- [Release notes](https://github.com/wvengen/proguard-maven-plugin/releases)
- [Changelog](https://github.com/wvengen/proguard-maven-plugin/blob/master/CHANGELOG.md)
- [Commits](https://github.com/wvengen/proguard-maven-plugin/commits)

---
updated-dependencies:
- dependency-name: com.github.wvengen:proguard-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-12-16 14:36:39 -08:00
dependabot[bot] cdf8ab5213
Bump bnd-maven-plugin from 6.0.0 to 6.1.0 (#2025)
Bumps [bnd-maven-plugin](https://github.com/bndtools/bnd) from 6.0.0 to 6.1.0.
- [Release notes](https://github.com/bndtools/bnd/releases)
- [Changelog](https://github.com/bndtools/bnd/blob/master/docs/ADDING_RELEASE_DOCS.md)
- [Commits](https://github.com/bndtools/bnd/compare/6.0.0...6.1.0)

---
updated-dependencies:
- dependency-name: biz.aQute.bnd:bnd-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-12-09 13:34:38 -08:00
yixingz3 eaf9a0342d
feat: added UPPER_CASE_WITH_UNDERSCORES in FieldNamingPolicy (#2024) 2021-11-28 09:33:22 -08:00
Éamonn McManus 6e06bf0d89 Fix for an ArrayIndexOutOfBoundsException.
The `fillBuffer` method changes `pos`, so it is incorrect to cache
its previous value.
2021-11-11 14:12:44 -05:00
Marcono1234 b0595c595b
Fix failing to serialize Collection or Map with inaccessible constructor (#1902)
* Remove UnsafeReflectionAccessor

Revert #1218

Usage of sun.misc.Unsafe to change internal AccessibleObject.override field
to suppress JPMS warnings goes against the intentions of the JPMS and does not
work anymore in newer versions, see #1540.
Therefore remove it and instead create a descriptive exception when making a
member accessible fails. If necessary users can also still use `java` command
line flags to open external modules.

* Fix failing to serialize Collection or Map with inaccessible constructor

Also remove tests which rely on Java implementation details.

* Don't keep reference to access exception of ConstructorConstructor

This also avoids a confusing stack trace, since the previously caught
exception might have had a complete unrelated stack trace.

* Remove Maven toolchain requirement

* Address review feedback

* Add back test for Security Manager
2021-11-09 07:16:35 -08:00
Marcono1234 ca2ed748ba
Fix warnings (#2014)
* Fix warnings

* Address review feedback
2021-11-07 08:43:49 -08:00
Marcono1234 cc505e1b9f
Convert codegen, metrics and proto to Maven submodules (#2008)
* Convert codegen, metrics and proto to Maven submodules

* Fix import order
2021-11-07 08:42:08 -08:00
Marcono1234 a92bbf849c
Improve TreeTypeAdapter thread-safety (#1976)
* Improve TreeTypeAdapter thread-safety

Gson claims to be thread-safe so TreeTypeAdapter.delegate() might be
called by multiple threads. To guarantee that each thread sees a fully
constructed `delegate`, the field has to be `volatile`.

* Improve TreeTypeAdapter thread race comment
2021-11-01 15:13:08 -07:00
Marcono1234 deaa3a6cd9
Fix `Gson.newJsonWriter` ignoring lenient and HTML-safe setting (#1989)
* Improve Gson newJsonWriter and newJsonReader documentation

* Consider lenient and HTML-safe setting for Gson.newJsonWriter

* Remove empty line between imports
2021-11-01 15:11:10 -07:00
Marcono1234 e0de45ff69
Delete unused LinkedHashTreeMap (#1992)
Class seems to be unused since commit f29d5bc37b.
Gson currently only uses LinkedTreeMap.
2021-11-01 15:09:14 -07:00
Marcono1234 b4dab86b10
Make default adapters stricter; improve exception messages (#2000)
* Make default adapters stricter; improve exception messages

* Reduce scope of synchronized blocks

* Improve JsonReader.getPath / getPreviousPath Javadoc
2021-11-01 15:08:04 -07:00
Marcono1234 b3188c1132
Fix `FieldNamingPolicy.upperCaseFirstLetter` uppercasing non-letter (#2004) 2021-11-01 15:05:04 -07:00
Éamonn McManus 031db9d473
Update CHANGELOG.md for 2.8.9. (#2005)
* Update CHANGELOG.md for 2.8.9.

* Adjust snapshot version. Gson versions have three numbers.
2021-10-29 13:41:12 -07:00
Éamonn McManus 128586847b [maven-release-plugin] prepare for next development iteration 2021-10-29 12:58:56 -07:00
Éamonn McManus 6a368d89da [maven-release-plugin] prepare release gson-parent-2.8.9 2021-10-29 12:58:54 -07:00
Marcono1234 ba96d53bad
Fix missing bounds checks for JsonTreeReader.getPath() (#2001)
There are situations where the stack of JsonTreeReader contains a JsonArray
or JsonObject without a subsequent Iterator, for example after calling peek()
or nextName().
When JsonTreeReader.getPath() is called afterwards it therefore must not
assume that a JsonArray or JsonObject is always followed by an Iterator.

The only reason why this never caused an ArrayIndexOutOfBoundsException in
the past is because the stack has an even default size (32) so it would just
have read the next `null`.
However, if the stack had for example the default size 31, a user created a
JsonTreeReader for 16 JSON arrays nested inside each other, then called 15
times beginArray(), followed by peek() and getPath() the exception would
occur.
2021-10-25 12:14:41 -07:00
Jaroslav Tulach ca1df7f7e0
#1981: Optional OSGi bundle's dependency on sun.misc package (#1993)
* #1981: Avoid OSGi bundle's dependency on sun.misc package

* Specify optional dependency on sun.misc.Unsafe

* Adjusting the test to sun.misc import being optional

* Using Collections.list and for loop

* Let the fail message include name of package

Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>

* Closing the input stream

* Dedicated assertSubstring method

Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
2021-10-25 11:32:10 -07:00
Marcono1234 c54caf308c
Deprecate `Gson.excluder()` exposing internal `Excluder` class (#1986) 2021-10-25 11:28:16 -07:00
Marcono1234 e6fae590cf
Prevent Java deserialization of internal classes (#1991)
Adversaries might be able to forge data which can be abused for DoS attacks.
These classes are already writing a replacement JDK object during serialization
for a long time, so this change should not cause any issues.
2021-10-13 10:14:57 -07:00
Marcono1234 bda2e3d16a
Improve number strategy implementation (#1987)
* Fix GsonBuilder not copying number strategies from Gson

* Improve ToNumberPolicy exception messages
2021-10-11 16:14:47 -07:00
Marcono1234 cd748df712
Fix LongSerializationPolicy null handling being inconsistent with Gson (#1990)
Gson does not actually use the specified LongSerializationPolicy but instead
uses type adapters which emulate the behavior. However, previously Gson's
implementation did not match LongSerializationPolicy regarding null handling.

Because it is rather unlikely that LongSerializationPolicy has been used on
its own, this commit adjusts its implementation to match Gson's behavior
(instead of the other way around).
2021-10-11 12:34:32 -07:00
Lyubomyr Shaydariv fe30b85224
Support arbitrary Number implementation for Object and Number deserialization (#1290)
* Object and Number type adapters number deserialization can be configured

* Change wording of ToNumberStrategy documentation

* Use inline links in doc sparingly

If the element has already been linked before, don't create a link for
every subsequent occurrence.

See also (slightly dated)
https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html#inlinelinks

* Link to default to-number policies in ToNumberStrategy doc

* Reduce code duplication for deserializing Number

* Hide default factory constants of NumberTypeAdapter and ObjectTypeAdapter

This encapsulates the logic a little bit better.
Additionally refactored factory created by NumberTypeAdapter to only create
TypeAdapter once and then have factory reuse that adapter for better
performance.

Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
2021-10-08 17:09:43 -07:00
dependabot[bot] 7b9a283a7a
Bump bnd-maven-plugin from 5.3.0 to 6.0.0 (#1985)
Bumps [bnd-maven-plugin](https://github.com/bndtools/bnd) from 5.3.0 to 6.0.0.
- [Release notes](https://github.com/bndtools/bnd/releases)
- [Changelog](https://github.com/bndtools/bnd/blob/master/docs/ADDING_RELEASE_DOCS.md)
- [Commits](https://github.com/bndtools/bnd/commits/6.0.0)

---
updated-dependencies:
- dependency-name: biz.aQute.bnd:bnd-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-10-06 17:58:02 -07:00
dependabot[bot] b0f3237bb8
Bump proguard-maven-plugin from 2.4.0 to 2.5.1 (#1980)
Bumps [proguard-maven-plugin](https://github.com/wvengen/proguard-maven-plugin) from 2.4.0 to 2.5.1.
- [Release notes](https://github.com/wvengen/proguard-maven-plugin/releases)
- [Changelog](https://github.com/wvengen/proguard-maven-plugin/blob/master/CHANGELOG.md)
- [Commits](https://github.com/wvengen/proguard-maven-plugin/commits)

---
updated-dependencies:
- dependency-name: com.github.wvengen:proguard-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-28 09:59:56 -07:00
Marcono1234 aa5554e69a
Don't exclude static local classes (#1969) 2021-09-17 18:12:47 -07:00
Marcono1234 f1f90313fc
Improve Maven build (#1964)
- Specify missing plugin versions
- Fix or suppress ProGuard notes and warnings
2021-09-17 17:19:50 -07:00
Nikita Novik 4f2aeaa288
Add license note to GSON POM file. (#1951)
* Add license note to GSON POM file.
2021-09-06 10:35:43 -07:00
Éamonn McManus c8f26dc907
Add missing calls when testing for exceptions. (#1948) 2021-08-31 15:03:45 -07:00
Éamonn McManus 1a2e58a42f
Remove an unused import. (#1947) 2021-08-31 14:55:07 -07:00
Simon Guerout 66fd2acdcf Fix formatting 2021-08-30 09:57:08 -07:00
Simon Guerout ac14b4c197 Make the nextJsonElement more robust
Add test cases
2021-08-30 09:57:08 -07:00
Simon Guerout 62a9702385 Improve the speed of the JSON_ELEMENT TypeAdapter when the object graph has already been turned into a JsonElement 2021-08-30 09:57:08 -07:00
Éamonn McManus 69173b02ea
Merge branch 'master' into optional-sql 2021-08-24 13:41:12 -07:00
Éamonn McManus b2f661166f [maven-release-plugin] prepare for next development iteration 2021-08-20 09:07:21 -07:00
Éamonn McManus b41030d3dc [maven-release-plugin] prepare release gson-parent-2.8.8 2021-08-20 09:07:19 -07:00
Éamonn McManus 9edaeb3b2e
Merge pull request #1909 from HiFromAjay/aj
Test cases for testing the exceptional behavior of JsonArray get... methods
2021-08-07 07:54:12 -07:00
HiFromAjay 01ab13f701 Remove unused imports [#1909, #1908] 2021-08-05 17:23:28 -06:00
Éamonn McManus df94ccdb48
Merge pull request #1925 from google/dependabot/maven/org.apache.maven.plugins-maven-resources-plugin-3.2.0
Bump maven-resources-plugin from 2.7 to 3.2.0
2021-08-05 06:28:52 -07:00
Éamonn McManus 80feb232b5
Merge pull request #1926 from google/dependabot/maven/com.github.wvengen-proguard-maven-plugin-2.4.0
Bump proguard-maven-plugin from 2.3.1 to 2.4.0
2021-08-05 06:28:12 -07:00
dependabot[bot] da2bfd7d1c
Bump copy-rename-maven-plugin from 1.0 to 1.0.1
Bumps [copy-rename-maven-plugin](https://github.com/coderplus/copy-rename-maven-plugin) from 1.0 to 1.0.1.
- [Release notes](https://github.com/coderplus/copy-rename-maven-plugin/releases)
- [Commits](https://github.com/coderplus/copy-rename-maven-plugin/commits)

---
updated-dependencies:
- dependency-name: com.coderplus.maven.plugins:copy-rename-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-05 03:03:02 +00:00
dependabot[bot] b7fce3850d
Bump proguard-maven-plugin from 2.3.1 to 2.4.0
Bumps [proguard-maven-plugin](https://github.com/wvengen/proguard-maven-plugin) from 2.3.1 to 2.4.0.
- [Release notes](https://github.com/wvengen/proguard-maven-plugin/releases)
- [Changelog](https://github.com/wvengen/proguard-maven-plugin/blob/master/CHANGELOG.md)
- [Commits](https://github.com/wvengen/proguard-maven-plugin/commits)

---
updated-dependencies:
- dependency-name: com.github.wvengen:proguard-maven-plugin
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-05 03:03:00 +00:00
dependabot[bot] 178b221fa0
Bump maven-resources-plugin from 2.7 to 3.2.0
Bumps [maven-resources-plugin](https://github.com/apache/maven-resources-plugin) from 2.7 to 3.2.0.
- [Release notes](https://github.com/apache/maven-resources-plugin/releases)
- [Commits](https://github.com/apache/maven-resources-plugin/compare/maven-resources-plugin-2.7...maven-resources-plugin-3.2.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-resources-plugin
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-05 03:02:56 +00:00
YOUNG HO CHA d8c5fcf00b Fix indentation of EnumWithObfuscatedTest 2021-08-04 12:30:07 +09:00
YOUNG HO CHA 59a8aedb37 Use SecurityManager to read enum fields 2021-08-04 12:24:55 +09:00
YOUNG HO CHA 20720d6a40 Remove unnecessary catch block 2021-08-04 12:03:28 +09:00
YOUNG HO CHA 6ac9f7d840 Suppress unchecked type cast warning 2021-08-04 12:03:21 +09:00
YOUNG HO CHA 92a98dab02 Removed unused import 2021-08-04 12:03:15 +09:00
YOUNG HO CHA e99a4b1cb7 Move testcases-proguard.conf into gson/src/test/resources 2021-08-04 12:03:10 +09:00
YOUNG HO CHA 1406477d0c Fix post-obfuscate-class task to include obfuscated test classes 2021-08-04 12:03:02 +09:00
YOUNG HO CHA 7988fbfa90 Update proguard plugin to support Java 11 compiler 2021-08-04 12:02:55 +09:00
YOUNG CHA 94f894cf44 Add testcase for obfuscated enum class 2021-08-04 12:02:50 +09:00
YOUNG CHA 68f99f2440 Make EnumTypeAdapter friendly with obfuscation
When enum value was obfuscated by proguard, EnumTypeAdapter raise NoSuchFieldException even if apply SerializedName annotation.
Because EnumTypeAdapter cannot find obfuscated enum constant field with its name.
2021-08-04 12:02:47 +09:00
Éamonn McManus 63e747f7f4
Merge pull request #1712 from rhernandez35/master
Fix fallback behavior of UnsafeReflectionAllocator when AccessibleObject isn't so accessible
2021-08-03 17:27:54 -07:00
Éamonn McManus 425cb25549 Adjust some minor details of #1391.
Use two-space indentation for the new test.
Use standard Google import style.
Supply missing type argument for `TypeVariable`.
2021-08-02 17:33:10 -07:00
Éamonn McManus d65960b001
Merge pull request #1391 from mcumings/issue1390
Fix issue with recursive type variable protections to fix #1390
2021-08-02 16:43:19 -07:00
HiFromAjay 2d1981d39b modify test cases for testing the exceptional behavior of get... methods [use fail(...), use JsonArray methods, remove unused values, formatting, #1909, #1908] 2021-06-14 14:31:14 -06:00
HiFromAjay 55115a5ca2 Test cases for testing the exceptional behavior of get, getAsBoolean, getAsDouble, getAsInt, getAsJsonArray, getAsJsonObject, getAsLong, and getAsString methods of JsonArray class. These test cases, which we wrote according to the specified behavior of each method, that helped us in identifying the documentation bugs in JsonArray and JsonElement classes, which we submitted issues for (Issue #1908). Note that we have adapted these test cases based on similar tests from the JSON-java project (https://github.com/stleary/JSON-java). 2021-06-11 10:04:32 -06:00
Éamonn McManus dadbdbb837 [maven-release-plugin] prepare for next development iteration 2021-05-24 16:22:45 -07:00
Éamonn McManus 4520489c29 [maven-release-plugin] prepare release gson-parent-2.8.7 2021-05-24 16:22:41 -07:00
Éamonn McManus 1e4b84c34f
Merge pull request #1687 from Marcono1234/iso-utils-test-fix
Fix ISO8601UtilsTest failing on systems with UTC+X
2021-05-13 17:19:26 -07:00
Éamonn McManus 829a514aed
Merge pull request #1786 from Marcono1234/marcono1234/JsonStreamParser-doc-fix
Improve incorrect JsonStreamParser doc
2021-05-13 16:45:36 -07:00
dependabot[bot] 83c63d2256
Bump bnd-maven-plugin from 4.0.0 to 5.3.0
Bumps [bnd-maven-plugin](https://github.com/bndtools/bnd) from 4.0.0 to 5.3.0.
- [Release notes](https://github.com/bndtools/bnd/releases)
- [Changelog](https://github.com/bndtools/bnd/blob/master/docs/ADDING_RELEASE_DOCS.md)
- [Commits](https://github.com/bndtools/bnd/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-13 23:31:27 +00:00
tiegen 9cf569698c
Update gson/src/main/java/com/google/gson/GsonBuilder.java
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
2021-04-26 10:36:30 +08:00
tiegen 527c6cf0d0
Update gson/src/main/java/com/google/gson/GsonBuilder.java
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
2021-04-26 10:36:02 +08:00
tiegen e6b7da988a
Update gson/src/test/java/com/google/gson/GsonTest.java
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
2021-04-25 16:34:26 +08:00
tiegen 8990169194
Update gson/src/test/java/com/google/gson/GsonTest.java
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
2021-04-25 16:34:18 +08:00
tiegen ccf8484915
Update gson/src/main/java/com/google/gson/GsonBuilder.java
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
2021-04-25 16:34:04 +08:00
tiegen 897452a3cf
Update gson/src/main/java/com/google/gson/GsonBuilder.java
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
2021-04-25 16:33:42 +08:00
tiegen 08765cae4c
Update gson/src/main/java/com/google/gson/GsonBuilder.java
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
2021-04-25 16:33:36 +08:00
saddays a0ea108c59 allow deserialize duplicate map key 2021-04-21 14:39:45 +08:00
Marcono1234 b1edb70486 Improve incorrect JsonStreamParser doc 2020-09-19 13:30:50 +02:00
Richard Hernandez b39494dbe6 Fix fallback behavior of UnsafeReflectionAllocator when AccessibleObject isn't so accessible 2020-05-26 20:12:36 -07:00
Marcono1234 a4a235e14a Remove redundant validation method 2020-05-24 23:54:32 +02:00
Marcono1234 4fb215c9df Move SQL types specific tests to separate test class 2020-05-23 23:31:03 +02:00
Marcono1234 380c4ec12c Make dependency on java.sql optional 2020-05-23 23:30:53 +02:00
Marcono1234 361292f1c1 Fix warnings 2020-05-09 17:34:53 +02:00
Marcono1234 541252a9fb Implement DefaultDateTypeAdapter in a type safer way 2020-05-09 17:34:52 +02:00
Marcono1234 9171715a88 Fix ISO8601UtilsTest failing on systems with UTC+X
Previously ISO8601UtilsTest.testDateFormatString() would fail on systems
where the time zone is UTC+X because getTime() returned "2018-06-24" for them.

Additionally the tests which previously changed the system locale and time
zone have been rewritten to create a UTC calendar instead. Setting locale
seems to not be necessary because ISO8601Utils.parse(...) does not do that
either.
2020-05-03 00:35:47 +02:00
Matthew Lee 55acc23d86
Fixing https://github.com/google/gson/issues/1592 (#1623)
adding null parameter check to name(), fixing the issue and being consistent with superclass behavior
2020-03-02 14:57:42 -08:00
Gabriel Basilio Brito fa947212e0
Add isEmpty method to JsonArray class (#1640)
The method will return true if the array is empty and false if it's not
2020-03-02 14:52:37 -08:00
Marcono1234 360cd3e2da
Remove unused files (#1654)
* Remove outdated javadocs folder

* Remove old release notes

* Remove unused Maven assembly plugin file

Plugin usage has been removed in 2016e95
2020-03-02 14:49:47 -08:00
Jiechuan Chen 4d735f1903
Add new testcases (#1638)
* Json Primitive Tests

* Json Tree Writer tests

* Add Tests for ISO8601Utils

* Add Tests for ISO8601Utils
2020-02-17 14:55:19 -08:00
Marcono1234 530cb74470
Fix javadoc doclint HTML warnings (#1653) 2020-02-17 14:46:15 -08:00
Marcono1234 adc4c1949d
Change links from HTTP to HTTPS (#1655) 2020-02-17 14:42:27 -08:00
Brian de Alwis 521fab2dd5 Fix OSGi metadata generation to work on JavaSE < 9 (#1603)
* Explicitly specify `Require-Capability: osgi.ee` to require 1.5+

Specifying disables bnd's auto-generated value which is determined from
the minimum versions of the .class files, including `module-info.class`

* Drop JavaSE-1.5 since that boat sailed a long time ago

* Drop unused org.apache.felix:maven-bundle-plugin plugin
2019-11-04 15:37:46 -08:00
Degubi 9bf25c2eb6 Refactor prefix array & loop logic, use if-s instead (#1505) 2019-10-04 13:45:06 -07:00
Inderjeet Singh d1828736eb [maven-release-plugin] prepare for next development iteration 2019-10-04 11:54:10 -07:00
Inderjeet Singh 29c93895bb [maven-release-plugin] prepare release gson-parent-2.8.6 2019-10-04 11:54:03 -07:00
Paul Kassianik 21fc362a7e Fixed tests for java 11 (#1454) 2019-10-04 11:29:13 -07:00
Degubi 20dca860dd Add docs to module-info.java (#1535) 2019-10-03 15:51:18 -07:00
Degubi 7845c38077 Minor cleanups in deprecations and other warnings (#1522) 2019-10-03 15:49:24 -07:00
David Maplesden 3958b1f78d Prefer writing chars instead of strings of length one (#1576)
This results in a noticeable performance improvement with most writer
implementations (including BufferedWriter).
2019-09-18 10:33:49 -07:00
Degubi 63ee47cb64 Refactor uppercaseFirstLetter, add additional field to test (#1515) 2019-04-26 15:49:22 -07:00
Degubi c5a3f21fba Refactor JsonParser to statics & fix tests 2019-04-15 22:35:10 -04:00
Degubi 477b3f77e1 Refactor primitives class 2019-04-15 11:08:31 -04:00
Degubi 46d0f58d12 Remove unnecessary explicit else statement 2019-04-05 16:20:06 +02:00
Degubi 3ee3c150ed Remove boolean wrappers in JsonElement 2019-03-31 21:28:12 +02:00
Degubi fc63a6af4c Make sql module dependency transitive (#1500) 2019-03-29 09:34:12 -07:00
Manuel Kollus 5370b076e3 Removing 'final' accessor from constructor (#1501) 2019-03-28 09:22:36 -07:00
Degubi 8bf2949c29 Remove object based constructors, remove some internal stuff 2019-03-11 10:53:31 -04:00
Jake Wharton a817604a41 Add test coverage for passing null to JsonPrimitive constuctors 2019-03-11 10:50:22 -04:00
Degubi bac26b8e42 Optimize array copies 2019-03-05 12:12:04 -05:00
Lorenz Nickel 3c6eea6b7d Adapt gson/gson/README to match with gson/README.md (#1472) 2019-03-03 11:28:00 -08:00
Lorenz Nickel b75e1bbc79 Code cleanup (Removed spaces) (#1474)
* Removed double spaces in comments

* Unified comments

* Removed space

* Removed spaces in code
2019-03-03 11:18:06 -08:00
Márton Braun 4d942db168 Update Gson.java documentation to explicitly state behavior for empty strings (#1464) 2019-02-17 00:32:43 -08:00
Piet van Dongen 5bbc768fa6 Fix JPMS module setup (fixes #1315) (#1402)
* Fix JPMS module setup (fixes #1315)

* Re-added cause to AssertionErrors
2018-10-18 08:49:08 -07:00
Mike Cumings 69f7c4e243 Replace instance equality checks in $Gson$Types#resolve 2018-09-26 22:38:53 -07:00
Mike Cumings e2296f42d5 Fix issue with recursive type variable protections to fix #1390
When a type variable is referenced multiple times it needs to resolve
to the same value.  Previously, the second attempt would abort
resolution early in order to protect against infinite recursion.
2018-09-25 16:09:48 -07:00
Eric Cochran 92b6173791 Deprecate JsonElement.getAsCharacter 2018-07-30 13:44:21 -04:00
Inderjeet Singh 986d3fb2fa [maven-release-plugin] prepare for next development iteration 2018-05-21 20:08:20 -07:00
Inderjeet Singh f649e05141 [maven-release-plugin] prepare release gson-parent-2.8.5 2018-05-21 20:08:09 -07:00
joel-leitch 4c685b21a8 Private constructor (#1324)
* Adding private constructors on Util classes

* Remove obsolete step
2018-05-21 20:04:22 -07:00
inder123 d84e26d80c
Issue 1242: Printing Gson version when throwing AssertionError and IllegalArgumentException (#1321)
On some versions of Android (probably on some variants of the popular Samsung S4 phone), an older version of Gson is suspected to be bundled in, and gets picked up from the system classpath.
For those versions, the applications that include the latest Gson fail unexpectedly. This debug print will help confirm this issue.
2018-05-17 09:41:21 -07:00
inder123 a6890bbaba
Fixed https://github.com/google/gson/issues/1310 (#1311)
* Fixed https://github.com/google/gson/issues/1310

Also renamed VersionUtils to more readable abstraction JavaVersion
Added support for debian naming convention
Using min supported version (6) as the default if JDK version can't be figured out

* Moved JavaVersion to an internal package
2018-05-09 13:10:08 -07:00
Inderjeet Singh 446a3bff8d [maven-release-plugin] prepare for next development iteration 2018-05-01 11:06:37 -07:00
Inderjeet Singh 9fbebdf990 [maven-release-plugin] prepare release gson-parent-2.8.4 2018-05-01 11:06:25 -07:00
inder123 049bf84e68
Using sun.misc.Unsafe only through reflection to avoid binary dependency (#1306)
If sun.misc.Unsafe not found on Java 9, try field.setAccessible
Also removed exception traces when sun.misc.Unsafe or override are not found
2018-05-01 09:57:45 -07:00
inder123 941363f14c
Added gradle/Idea support (#1302) 2018-04-30 09:54:24 -07:00
inder123 1b28ff3cda
Added a test for deserialization of fields using lowercase-dot naming policy (#1303) 2018-04-27 18:54:48 -07:00
Leon ab35f11077 add FieldNamingPolicy.LOWER_CASE_WITH_DOTS (#1278) 2018-04-27 18:50:08 -07:00
Inderjeet Singh 7dd379ffe1 [maven-release-plugin] prepare for next development iteration 2018-04-27 15:34:26 -07:00
Inderjeet Singh 4ed639e882 [maven-release-plugin] prepare release gson-parent-2.8.3 2018-04-27 15:34:15 -07:00
Lyubomyr Shaydariv bdea5b9e99 Removed the executable flag from clearly text files 2018-04-26 10:23:15 +03:00
Inderjeet Singh 4081dbaa6d Added a test for serialization/deserialization of enum classes with
fields
2018-03-17 16:00:46 -07:00
Andrey Mogilev 8445689e4d Java 9 support: use Unsafe-based reflection in Java 9+ (#1218)
* Java 9 support: use Unsafe-based reflection in Java 9+

fixes "illegal reflective access" warnings and exceptions

* fix Codacy warnings

* improve code quality based on PR review

* improve code quality based on PR review

* fix Codacy warning

* improve code quality based on PR review

* inlined createReflectionAccessor method
2018-01-04 00:38:50 +05:30
Andrey Mogilev 0aaf5ff408 fix Java9 DateFormat changes (#1211)
* fix Java9 DateFormat changes

* fix Codacy warnings
2017-12-30 00:44:43 +05:30
Anirudh Ramanan 3bf1967c0a Optimised the create() call for Excluder TypeAdapterFactory (#1199)
* optimized the create() method, excludeClass used to get called two times, changed it to one

* fixed the create() method, and added support to disableAnonymousAndLocalClassSerialization

* peek only once

* enable anonymous and local class serialization

* bugfix

* removed the method, will raise it as a separate PR
2017-12-28 06:03:45 +05:30
michaelsavich 7ddac52748 Java 9 module (#1179)
* Add module-info.java

* Exclude module-info.java by default
2017-12-26 21:58:19 +05:30
Trung Do 855f0493d0 Fix a small typo (#1183) 2017-10-31 11:43:24 -07:00
Andrey Mogilev b1fb9ca9a1 fix issue #1107: resolve element type in wildcard collection types (#1146)
* fix issue #1107: resolve element type in wildcard collection types

* fix Codacy warnings

* fix Codacy warnings
2017-09-21 17:50:41 -07:00
Warren Smith 08bbb226f1 Add newBuilder() API (#1142)
* Add Gson.newBuilder API.

* Remove redundant test.

* Address Codacy comments.

* Reduce visibility of GsonBuilder constructor.
2017-09-20 18:53:10 -07:00
Inderjeet Singh c0b50ba3a3 [maven-release-plugin] prepare for next development iteration 2017-09-19 18:41:44 -07:00
Inderjeet Singh d90f63dc88 [maven-release-plugin] prepare release gson-parent-2.8.2 2017-09-19 18:41:34 -07:00
Nels Beckman ddcd6aea7d Update fromJson Javadoc. (#1151)
For the string-based fromJson() method, mention that the result will be null if the given string is empty.
2017-09-18 00:08:22 -07:00
Lyubomyr Shaydariv 7a9fd5962d Fixed DefaultDateTypeAdapter nullability issue and JSON primitives contract (#1100)
* Fixed DefaultDateTypeAdapter nullability issue and JSON primitives contract

Regression in:

* b8f616c939 - Migrate DefaultDateTypeAdapter to streaming adapter (#1070)

Bug reports:

* https://github.com/google/gson/issues/1096 - 2.8.1 can't serialize and deserialize date null (2.8.0 works fine)
* https://github.com/google/gson/issues/1098 - Gson 2.8.1 DefaultDateTypeAdapter is not null safe.

* Fixed DefaultDateTypeAdapter nullability on write
2017-09-17 23:49:13 -07:00
Warren Smith d9cc7bc60b Make GsonBuilder.create() factory order idempotent. (#1141) 2017-08-14 08:56:16 -07:00
Tom Magnusson 68cf8fdc95 fix typo in ConstructorConstructor exception 2017-08-03 09:28:31 -04:00
Andrey Mogilev 03a72e752e Fix StackOverflowError on resolving types with TypeVariable recursion (#1128)
* Fix StackOverflowError on resolving types with TypeVariable recursion

Sample failing code:
  private static class TestType<X> {
    TestType<? super X> superType;
  }
  ...
  new Gson().getAdapter(TestType.class);

* fix build errors
2017-07-31 10:50:29 -07:00
Igor Mysak ee691fba43 fix javaDoc (#1122) 2017-07-21 10:12:25 -07:00
inder123 3090a7ed2a Made deepCopy public (#1091)
* Made deepCopy public

* since 2.8.2
2017-05-31 10:33:37 -07:00
Mike ada597e69a value(double) can write NaN and infinite values when lenient, as value(Number) does (#1093)
* Added test which shows that lenient JsonWriter fails writing infinite primitive doubles, but does not fail writing boxed doubles, as stated in #1090.

* Fixed JsonWriter#value(double) to write infinite and NaN values when lenient, as JsonWriter#value(Number) does. (fixes #1090)
2017-05-31 09:50:44 -07:00
Inderjeet Singh 0aaef0fd1b [maven-release-plugin] prepare for next development iteration 2017-05-30 18:38:01 -07:00
Inderjeet Singh 3e74bb47d1 [maven-release-plugin] prepare release gson-parent-2.8.1 2017-05-30 18:37:51 -07:00
Lyubomyr Shaydariv b8f616c939 Migrate DefaultDateTypeAdapter to streaming adapter (#1070) 2017-05-30 18:12:50 -07:00
Andrey Mogilev a300148003 Fix StackOverflowError on resolving recursive types by collapsing chains of type bounds (#1075)
* Fixes StackOverflowError on resolving recursive types.

See Issue #440, Issue #603, tests.

* fix 'codacy' coding style warnings

* added copyright header
2017-05-30 17:47:04 -07:00
sourabh gupta 5848096f3e Size allocation of StringBuilder (#1047)
Size allocation of StringBuilder
2017-05-24 15:49:09 -07:00
James Carman f7012e5865 Adding maven-bundle-plugin. (#1071) 2017-05-24 15:25:50 -07:00
Jake Wharton b58de2f4ae Merge pull request #1073 from lyubomyr-shaydariv/public-tojson
Remove helper methods mentioned in the TODO list
2017-05-02 10:37:11 -04:00
Lyubomyr Shaydariv eb27d55f49 Remove helper methods mentioned in the TODO list 2017-04-23 15:54:10 +03:00
Eric Cochran 3270e8d972 Remove need for synthetic accessor methods. 2017-04-22 17:32:59 -07:00
inder123 5412f21431 Printing more debugging information to help track an invalid JsonAdapter. (#1068)
Now the thrown exception carries this information:
java.lang.IllegalArgumentException: Invalid attempt to bind an instance of java.lang.Integer as a @JsonAdapter for com.google.gson.functional.JsonAdapterAnnotationOnClassesTest$D. @JsonAdapter value must be a TypeAdapter, TypeAdapterFactory, JsonSerializer or JsonDeserializer.
2017-04-19 17:08:21 -07:00
Michele Vivoda 9a2421997e negative zero test and fix (#1069) 2017-04-19 14:26:36 -07:00
Mohammad Yasir 92b52d25d8 Performance fix to avoid reflection-based initialization of null key surrogate 2017-04-12 16:11:20 -04:00
sourabh gupta 441fa98735 Simplified access of getSimpleName (#1042)
* Simplified access of getSimpleName

instead of calling getClass.getSimpleName() that will check too many conditions inside , we can make it as final String and use it directly.

* Simplified access of getSimpleName

making string as static

* Simplified access of getSimpleName

Code Review changes
2017-03-20 14:25:52 -07:00
Jesse Wilson 423ff04a75 Merge pull request #1037 from guptasourabh/master
elimiating code overhead
2017-03-18 15:34:09 -04:00
guptasourabh 8101ab74e9 list addition optimization (#1038)
* list addition optimization

* Optimized imports

Optimized imports
2017-03-16 21:16:38 -07:00
Sourabh Gupta d0e70bcdbf elimiating code overhead 2017-03-15 22:41:42 +05:30
guptasourabh fd37cf1d0d JsonArray with capacity in constructor (#1033)
JsonArray with capacity in constructor
2017-03-12 19:59:41 -07:00
Anirudh Ramanan 9e44d60b83 Eliminating code overhead
* calculating size of the list once in case of loops, avoided creation of string builder object if the length type argument is 0
* replaced null check boilerplate code with nullSafe()
2017-03-01 11:13:56 -05:00
Mohammad Yasir 4644837207 Incorporating the review comments. While more than 1 charachter might be read from the buffer the output will have only one escaped charachter. 2017-02-17 11:54:30 +05:30
Jesse Wilson 2d072bae3a Merge pull request #1015 from yasirmhd/master
Memory optimisation in JsonReader
2017-02-16 22:58:16 -05:00
Mohammad Yasir 9c30b0e203 Incorporating code review suggestions 2017-02-17 07:25:23 +05:30
André Rouél 9e6f2bab20 Fix ArrayIndexOutOfBoundsException when skipping a value with JsonTreeReader #1013 (#1014) 2017-02-15 18:41:39 -08:00
Mohammad Yasir ba4643134a Removing unused variable 2017-02-16 03:00:02 +05:30
Mohammad Yasir 410b4a8c62 Optimizing for memory 2017-02-16 02:51:02 +05:30
BloodShura 9d8d7a43e1 All JsonElement::getAsJsonXXX methods now include the JSON string on thrown exception's message 2017-02-07 22:04:22 -02:00
Martin Lind 08c7bffba0 Fix for #957 (#994) 2017-01-11 10:38:33 -08:00
Yutaro Iino 9e5e4ac630 Add missing comma in toString() 2016-12-21 00:10:42 +09:00
Mark Hess 4976e420fc Add keySet method and test (#942) 2016-12-13 22:15:49 -08:00
Kevin Most 5f73666404 Update JsonAdapter documentation (#976)
Include mention of JsonDeserializer and JsonSerializer.
2016-12-11 22:37:55 -08:00
Egor Neliuba 44cad04a63 Allow deserialization of a Number represented as a String (#964) 2016-11-25 23:40:14 -08:00
jwilson 14c8c1a82b [maven-release-plugin] prepare for next development iteration 2016-10-26 23:01:41 -07:00
jwilson e9ead40302 [maven-release-plugin] prepare release gson-parent-2.8.0 2016-10-26 23:01:37 -07:00
Inderjeet Singh 688f918a35 Added @Documented to Gson annotations.
This is useful since it shows the JSON format for a class which the user of that class should typically know.
2016-09-15 18:24:21 -07:00
Jake Wharton 9414b9b3b6 Add static factories for array and parameterized type tokens.
These are useful when creating TypeAdapterFactories that delegate to others with more complex types. They also are useful when writing dynamic code that deals with types that cannot be fully reified using the normal subclass technique.
2016-08-12 12:11:57 -04:00
testcenter 193349f4aa made nullSafe wrapper of JsonAdapter optional 2016-06-28 09:18:03 +02:00
Inderjeet Singh 0a29fcf859 [maven-release-plugin] prepare for next development iteration 2016-06-14 16:52:32 -07:00
Inderjeet Singh 9722b00372 [maven-release-plugin] prepare release gson-parent-2.7 2016-06-14 16:52:28 -07:00
Inderjeet Singh 687ddb319e Preparing 2.7-SNAPSHOT to cut the 2.7 release. 2016-06-14 16:39:19 -07:00
inder123 b2c00a3b02 Merge pull request #873 from google/jwilson.0601.get_delegate_adapter
Add support for JsonSerializer/JsonDeserializer in the JsonAdapter annotation
2016-06-14 16:37:14 -07:00
Inderjeet Singh 1f859ec769 addressed code review comments. 2016-06-14 16:34:34 -07:00
Jesse Wilson c24af30407 Merge pull request #871 from google/jw/tree-json-path
Implement JSON Path for JsonTreeReader.
2016-06-09 23:32:24 -07:00
Jake Wharton c16be41e77 Expose JsonObject size. 2016-06-10 00:46:32 -04:00
Jake Wharton c2fae85a9f Implement JSON Path for JsonTreeReader. 2016-06-10 00:14:28 -04:00
inder123 ebad966efd Merge pull request #870 from google/jw/reader-location
Consolidate location and path rendering for exceptions.
2016-06-09 15:26:10 -07:00
Jake Wharton ecaa57114f Consolidate location and path rendering for exceptions. 2016-06-09 18:02:36 -04:00
Archit Dey 3f8726ecaf Enhancing the json reader, adding corresponding test case for it 2016-06-02 09:19:43 -04:00
jwilson 2df65502ed Don't use ThreadLocals for @JsonAdapter factories and getDelegateAdapter(). 2016-06-02 00:33:09 -04:00
Inderjeet Singh 943c674276 Removed ThreadLocal for activeJsonAdapterClasses 2016-06-02 00:08:25 -04:00
Inderjeet Singh 45511fdd15 Added support for JsonSerializer/JsonDeserializer for JsonAdapter annotation.
JsonAdapter is cached per the type of the JsonAdapter class.
Added a test to ensure JsonAdapter works on fields of parameterized types
Keep track of registered JsonAdapters and JsonAdapterFactorys in ThreadLocal.
2016-06-02 00:08:25 -04:00
Jesse Wilson bb451eac43 Merge pull request #832 from google/831
Ensuring that JsonAdapter annotation works correctly for primitive fi…
2016-05-17 17:26:52 -04:00
Inderjeet Singh 3ff16c30db Don't use a runtime wrapper if a JsonAdapter annotation is present on a field.
This ensures that JsonAdapter annotation works correctly on a primitive field.
This is a potentially backward incompatible change.
2016-05-17 13:30:59 -07:00
Inderjeet Singh 61f83d6309 Replaced a JDK 1.7 specific method with its JDK 1.6 equivalent. 2016-05-17 01:03:00 -07:00
Baschdl c414b368e1 Corrected documentation, copy&paste error 2016-05-12 14:47:03 +02:00
Jake Wharton 371aff7ce4 Switch default Queue implementation to ArrayDeque.
Now that we require Java 1.6 or newer this much more efficient implementation can be used as the default.
2016-04-27 00:37:28 -04:00
Jake Wharton 8537c8932f Optimize list allocation for every reflective field.
The common cases (no @SerializedName and a single-value @SerializedName) now use a specialized one-element collection. Cases with alternate names use a much more space efficient ArrayList which is exactly sized.

This is also a performance win for adapter initialization since an index-based loop was used on the returned type for which LinkedList is not suited for.
2016-04-27 00:28:51 -04:00
Ryan Harter a851569ab9 Adds getters for config fields.
This adds simple getters for certain config fields that would be helpful in custom
TypeAdapters to deal with situations like this:
https://github.com/rharter/auto-value-gson/issues/18
2016-04-26 15:30:01 -04:00
Jake Wharton 59edfc1caf Add boxed boolean value() overload.
When calling value() with a Boolean overload resolution would choose value(boolean) which would throw an NPE on null. The other boxed types are all numbers which would resolve to value(Number) and behave correctly.
2016-04-22 19:52:38 -04:00
Jesse Wilson 0f66f4fac4 Merge pull request #829 from ionspin/master
Check if class can be instantiated based on class modifiers. Fix for #817
2016-04-22 06:47:08 -10:00
Ugljesa Jovanovic ab40462cc7 Check if class can be instantiated based on class modifiers. If not throw an unsupported operation exception. 2016-04-20 10:43:34 +02:00
gavlyukovskiy 966de9e60d fixed throwing RuntimeException instead of JsonIOException 2016-04-15 21:00:59 +03:00