我有具有以下结构的大型 xml 树:
<?xml version="1.0"?>
<SampleElem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Children>
<SampleElem>
<Children/>
<Id>1</Id>
<Value>Test2</Value>
</SampleElem>
</Children>
<Id>-1</Id>
<Value>Test1</Value>
</SampleElem>
我正在尝试使用simpleframework反序列化它:
Serializer serializer = new Persister();
SampleElem root = serializer.read(SampleElem.class, someStream, false);
一段时间后,应用程序因错误而停止。从设备记录:
E/AndroidRuntime(13591): FATAL EXCEPTION: AsyncTask #1
E/AndroidRuntime(13591): java.lang.RuntimeException: An error occured while executing doInBackground()
E/AndroidRuntime(13591): at android.os.AsyncTask$3.done(AsyncTask.java:200)
E/AndroidRuntime(13591): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
E/AndroidRuntime(13591): at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
E/AndroidRuntime(13591): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
E/AndroidRuntime(13591): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
E/AndroidRuntime(13591): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
E/AndroidRuntime(13591): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
E/AndroidRuntime(13591): at java.lang.Thread.run(Thread.java:1019)
E/AndroidRuntime(13591): Caused by: java.lang.StackOverflowError
E/AndroidRuntime(13591): at java.lang.StringBuilder.append(StringBuilder.java:217)
E/AndroidRuntime(13591): at java.lang.reflect.Modifier.toString(Modifier.java:285)
E/AndroidRuntime(13591): at java.lang.reflect.Method.toString(Method.java:538)
E/AndroidRuntime(13591): at java.lang.reflect.Method.equals(Method.java:361)
E/AndroidRuntime(13591): at org.apache.harmony.lang.annotation.AnnotationFactory.invoke(AnnotationFactory.java:307)
E/AndroidRuntime(13591): at $Proxy1.inline(Native Method)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.ElementListLabel.getConverter(ElementListLabel.java:160)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.CacheLabel.getConverter(CacheLabel.java:280)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.readVariable(Composite.java:604)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.readInstance(Composite.java:573)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.readUnion(Composite.java:549)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.readElement(Composite.java:532)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.readElements(Composite.java:445)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.access$400(Composite.java:59)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite$Builder.read(Composite.java:1383)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.read(Composite.java:201)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.read(Composite.java:148)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Traverser.read(Traverser.java:92)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.CompositeList.populate(CompositeList.java:175)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.CompositeList.read(CompositeList.java:120)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.readVariable(Composite.java:623)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.readInstance(Composite.java:573)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.readUnion(Composite.java:549)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.readElement(Composite.java:532)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.readElements(Composite.java:445)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.access$400(Composite.java:59)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite$Builder.read(Composite.java:1383)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.read(Composite.java:201)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.read(Composite.java:148)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Traverser.read(Traverser.java:92)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.CompositeList.populate(CompositeList.java:175)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.CompositeList.read(CompositeList.java:120)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.readVariable(Composite.java:623)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.readInstance(Composite.java:573)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.readUnion(Composite.java:549)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.readElement(Composite.java:532)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.readElements(Composite.java:445)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.access$400(Composite.java:59)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite$Builder.read(Composite.java:1383)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.read(Composite.java:201)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.read(Composite.java:148)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Traverser.read(Traverser.java:92)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.CompositeList.populate(CompositeList.java:175)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.CompositeList.read(CompositeList.java:120)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.readVariable(Composite.java:623)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Composite.readInstance(Composite.java:573)
E/AndroidRuntime(13591): at org.simpleframework.xml.core.Compos
数据完全正确,输入的xml完全有效。你有什么想法?
谢谢!
更新:
树策略呢?它应该如何使用?你有什么例子吗?