我一直在試圖反序列化一個由android應用程序中的普通JDK創建的對象,每當我嘗試這樣做時,我都會收到一個StackOverFlowError。當在android中反序列化一個對象時出現StackOverFlowError
我可以使用在davlik vm中使用JDK序列化的對象嗎?文件大小爲4 MB及其存儲在資產文件夾,產生錯誤的行是以下
trie = (Trie<String, String>) new ObjectInputStream(ctx.getAssets().open(FILE_NAME)).readObject();
02-10 15:27:41.036: E/AndroidRuntime(2019): FATAL EXCEPTION: main
02-10 15:27:41.036: E/AndroidRuntime(2019): java.lang.StackOverflowError
02-10 15:27:41.036: E/AndroidRuntime(2019): at java.io.DataInputStream.readUnsignedShort(DataInputStream.java:414)
02-10 15:27:41.036: E/AndroidRuntime(2019): at java.io.DataInputStream.readUTF(DataInputStream.java:433)
02-10 15:27:41.036: E/AndroidRuntime(2019): at java.io.ObjectInputStream.readNewString(ObjectInputStream.java:2171)
02-10 15:27:41.036: E/AndroidRuntime(2019): at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:918)
02-10 15:27:41.036: E/AndroidRuntime(2019): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2262)
02-10 15:27:41.036: E/AndroidRuntime(2019): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2217)
02-10 15:27:41.036: E/AndroidRuntime(2019): at java.io.ObjectInputStream.readFieldValues(ObjectInputStream.java:1291)
02-10 15:27:41.036: E/AndroidRuntime(2019): at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:518)
02-10 15:27:41.036: E/AndroidRuntime(2019): at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1535)
02-10 15:27:41.036: E/AndroidRuntime(2019): at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1443)
....
4 MiB是堆棧中的一部分...您是否嘗試將更多的內存分配給Java VM? – m0skit0 2012-02-10 11:39:26
@ m0skit0我直接在手機上運行它 – OKAN 2012-02-10 11:42:12