我StackOverflowError
在尝试将对象写入 json with 时遇到了问题com.badlogic.gdx.utils.Json
,这是基于jsonbeans的。除了对 ShapeRenderer 的引用之外,该对象及其引用的所有对象仅包含原始变量,例如 float、boolean、int 等。多个对象都引用同一个 ShapeRenderer。有一些循环引用(对象都相互引用),但我认为它应该能够处理。
这些错误的原因可能是什么?循环引用有问题吗?如果不回到绘图板并重组我的应用程序的主要部分,我就不能简单地删除它们。
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)
这持续了大约 1024 行:
at com.badlogic.gdx.utils.Json.writeValue(Json.java:492)
at com.badlogic.gdx.utils.Json.writeFields(Json.java:237)
不确定这是日志限制还是堆栈限制,我猜是第一个。