java.lang.StackOverflowError at com.google.gson.internal.$Gson$Types.resolve
See original GitHub issuewhile 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:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
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.