在 android API 10 上使用 LinkedList 保存对象时出现错误:
08-10 14:37:45.091: E/AndroidRuntime(29845): FATAL EXCEPTION: Thread-17 08-10 14:37:45.091: E/AndroidRuntime(29845): java.lang.IllegalArgumentException: no char field 'exponential' 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.EmulatedFields.put(EmulatedFields.java:459) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.EmulatedFieldsForDumping.put(EmulatedFieldsForDumping.java:83) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.text.DecimalFormatSymbols.writeObject(DecimalFormatSymbols.java:591) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.lang.reflect.Method.invokeNative(Native Method) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.lang.reflect.Method.invoke(Method.java:507) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1219) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1575) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1847) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1689) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1653) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:1062) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeFields(ObjectOutputStream.java:1008) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.text.DecimalFormat.writeObject(DecimalFormat.java:1215) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.lang.reflect.Method.invokeNative(Native Method) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.lang.reflect.Method.invoke(Method.java:507) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1219) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1575) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1847) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1689) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1653) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:1143) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:413) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1241) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1205) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1575) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1847) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1689) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1653) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:1143) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:413) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1241) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1575) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1847) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1689) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1653) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.util.LinkedList.writeObject(LinkedList.java:973) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.lang.reflect.Method.invokeNative(Native Method) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.lang.reflect.Method.invoke(Method.java:507) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1219) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1575) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1847) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1689) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1653) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:1143) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:413) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1241) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1575) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1847) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1689) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1653) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.util.LinkedList.writeObject(LinkedList.java:973) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.lang.reflect.Method.invokeNative(Native Method) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.lang.reflect.Method.invoke(Method.java:507) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1219) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1575) 08-10 14:37:45.091: E/AndroidRuntime(29845): at java.io.Ob
我不知道故障在哪里,我不认为自 API 1 以来链表是一个问题,但它不会在 android API 18 上发生,知道哪里有问题吗?
保存:
FileOutputStream fos = null;
try {
fos = openFileOutput("shelf.obj", Context.MODE_PRIVATE);
ObjectOutputStream out = new ObjectOutputStream(fos);
out.writeObject(listOfShelfs);
out.close();
fos.close();
} catch (FileNotFoundException e) {
//catch
} catch (IOException e) {
//catch
}
要保存的对象:
private static HashMap<String, MessageShelf> listOfShelfs = new HashMap<String, MessageShelf>();
留言架:
public class MessageShelf implements Serializable{
private static final long serialVersionUID = 1L;
public Friend correspodent;
Calendar lastSeen;
Calendar lastSend;
boolean secure;
Queue<MessageList> historyMessagesLists=new LinkedList<MessageList>();
public String lastMessageBody = "";
public Calendar lastDate;}