question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java.lang.StackOverflowError at com.google.gson.internal.$Gson$Types.resolve

See original GitHub issue

while doing code

  import java.util.Timer;

  Gson gson = new Gson();
   Timer tmr = new Timer();
   System.out.println(gson.toJson(tmr));

I have got error


java.lang.StackOverflowError
	at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:353)
	at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:378)
	at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:383)
	at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:378)
	at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:383)
	at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:378)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
amogilevcommented, Feb 6, 2018

The line numbers in your stacktrace do not correspond to $Gson$Types.resolve calls in 2.8.2. Probably you have got it on older version.

In 2.8.2, there is StackOverflowError for Timer as well, but it is related to actual circular references, and do not include any $Gson$Types.resolve() lines in the stacktrace

0reactions
Marcono1234commented, Sep 10, 2022

Gson does not provide a built-in adapter for java.util.Timer and therefore uses reflection to serialize it. In general you should avoid using reflection-based serialization for third party classes because you will then depend on their internal implementation details which could change at any point.

Most likely this specific issue with $Gson$Types.resolve has also already been fixed in the latest Gson version because some pull requests related to this have been merged in the past.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.lang.StackOverflowError at com.google.gson.internal ...
java.lang.StackOverflowError at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:378) ... I'm implementing "RealM" in my Android app.
Read more >
Why does this Gson cause a stackOverflow exception? - Reddit
java.lang.StackOverflowError at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375) at com.google.gson.internal.
Read more >
Solved - GSON Stack Overflow error - SpigotMC
Hey, so I'm making a Skyblock plugin and I'm attempting to use GSON to convert the Island instance into JSON format. I'm getting...
Read more >
Issue 440 in google-gson: Infinity loop at recursive calling com ...
Gson$Types.resolve($Gson$Types.java:375). 1229 views ... at com.google.gson.internal. ... 01-18 13:32:10.146: E/AndroidRuntime(831): java.lang.
Read more >
[Unresolved] Gson error (StackOverflowError) - Bukkit Forums
java.lang.StackOverflowError at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found