Libgdx JsonWriter StackOverflowError-Collection of common programming errors
I’m getting a StackOverflowError
when trying to write an object to json with com.badlogic.gdx.utils.Json
, which is based on jsonbeans. The object and all objects it references only contain primitive variables like float, boolean, int, etc except for references to a ShapeRenderer. Multiple objects all reference the same ShapeRenderer. There are some circular references (objects both having a reference to each other) but i assume it should be able to handle that.
What could be the cause of these errors? Are the circular references the problem? I can’t simply remove them without going back to the drawing board and restructuring major parts of my app.
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.StackOverflowError
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:111)
Caused by: java.lang.StackOverflowError
at java.util.regex.Pattern$CharProperty$1.isSatisfiedBy(Unknown Source)
at java.util.regex.Pattern$7.isSatisfiedBy(Unknown Source)
at java.util.regex.Pattern$7.isSatisfiedBy(Unknown Source)
at java.util.regex.Pattern$7.isSatisfiedBy(Unknown Source)
at java.util.regex.Pattern$7.isSatisfiedBy(Unknown Source)
at java.util.regex.Pattern$CharProperty.match(Unknown Source)
at java.util.regex.Pattern$Curly.match0(Unknown Source)
at java.util.regex.Pattern$Curly.match(Unknown Source)
at java.util.regex.Pattern$CharProperty.match(Unknown Source)
at java.util.regex.Matcher.match(Unknown Source)
at java.util.regex.Matcher.matches(Unknown Source)
at com.badlogic.gdx.utils.JsonWriter$OutputType.quoteName(JsonWriter.java:174)
at com.badlogic.gdx.utils.JsonWriter.name(JsonWriter.java:46)
at com.badlogic.gdx.utils.JsonWriter.set(JsonWriter.java:113)
at com.badlogic.gdx.utils.Json.writeType(Json.java:574)
at com.badlogic.gdx.utils.Json.writeObjectStart(Json.java:533)
at com.badlogic.gdx.utils.Json.writeValue(Json.java:491)
at com.badlogic.gdx.utils.Json.writeFields(Json.java:237)
at com.badlogic.gdx.utils.Json.writeValue(Json.java:492)
at com.badlogic.gdx.utils.Json.writeFields(Json.java:237)
at com.badlogic.gdx.utils.Json.writeValue(Json.java:492)
at com.badlogic.gdx.utils.Json.writeFields(Json.java:237)
at com.badlogic.gdx.utils.Json.writeValue(Json.java:492)
at com.badlogic.gdx.utils.Json.writeFields(Json.java:237)
This goes on for about 1024 lines:
at com.badlogic.gdx.utils.Json.writeValue(Json.java:492)
at com.badlogic.gdx.utils.Json.writeFields(Json.java:237)
Not sure whether that’s the log limit or the stack limit, i guess the first one.