XStream
  1. XStream
  2. XSTR-208

Error when deserializing java.awt.Font

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2
    • Component/s: None
    • Labels:
      None
    • JDK version and platform:
      1.4.0_01 on Windoes 98SE

      Description

      I'm getting an error when deserializing a Font. These is a brief code that reproduces the error:

      XStream xstream =new XStream(new PureJavaReflectionProvider());
      xstream.registerConverter(new FontConverter());

      Font f = new Font("",Font.ITALIC,12);

      //FOR SERIALIZATION
      try

      { ObjectOutputStream out = xstream.createObjectOutputStream(new FileWriter("c:\\font.xml")); out.writeObject(f); out.flush(); out.close(); System.out.println("Serialized"); }

      catch(Exception e)

      { e.printStackTrace(); }

      //FOR DESERIALIZATION
      try {
      ObjectInputStream in = xstream.createObjectInputStream(new FileReader("c:
      font.xml"));
      Font c = (Font)in.readObject();
      System.out.println("Deserialized");
      System.out.println(c.toString());
      } catch(Exception e) {
      e.printStackTrace();
      }

      This is the StackTrace:

      com.thoughtworks.xstream.converters.ConversionException: : unknown attribute name
      ---- Debugging information ----
      cause-exception : com.thoughtworks.xstream.converters.reflection.ObjectAccessException
      required-type : java.awt.font.TextAttribute
      class : java.awt.Font
      message : : unknown attribute name
      line number : 5
      path : /awt-font/attributes/entry/java.awt.font.TextAttribute
      cause-message : : unknown attribute name
      -------------------------------
      at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:45)
      at com.thoughtworks.xstream.core.ReferenceByXPathUnmarshaller.convertAnother(ReferenceByXPathUnmarshaller.java:39)
      at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:82)
      at com.thoughtworks.xstream.converters.collections.MapConverter.populateMap(MapConverter.java:68)
      at com.thoughtworks.xstream.converters.collections.MapConverter.unmarshal(MapConverter.java:59)
      at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:38)
      at com.thoughtworks.xstream.core.ReferenceByXPathUnmarshaller.convertAnother(ReferenceByXPathUnmarshaller.java:39)
      at com.thoughtworks.xstream.converters.extended.FontConverter.unmarshal(FontConverter.java:31)
      at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:38)
      at com.thoughtworks.xstream.core.ReferenceByXPathUnmarshaller.convertAnother(ReferenceByXPathUnmarshaller.java:39)
      at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:99)
      at com.thoughtworks.xstream.core.ReferenceByXPathMarshallingStrategy.unmarshal(ReferenceByXPathMarshallingStrategy.java:12)
      at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:549)
      at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:528)
      at com.thoughtworks.xstream.XStream$2.readFromStream(XStream.java:798)
      at com.thoughtworks.xstream.core.util.CustomObjectInputStream.readObjectOverride(CustomObjectInputStream.java:66)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:316)
      at SerialXStream2.main(SerialXStream2.java:74)
      Caused by: com.thoughtworks.xstream.converters.reflection.ObjectAccessException: : unknown attribute name
      at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.instantiateUsingSerialization(PureJavaReflectionProvider.java:93)
      at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.newInstance(PureJavaReflectionProvider.java:48)
      at com.thoughtworks.xstream.converters.reflection.ReflectionConverter.instantiateNewInstance(ReflectionConverter.java:145)
      at com.thoughtworks.xstream.converters.reflection.ReflectionConverter.unmarshal(ReflectionConverter.java:87)
      at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:38)
      ... 17 more
      Caused by: java.io.InvalidObjectException: unknown attribute name
      at java.awt.font.TextAttribute.readResolve(TextAttribute.java:116)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:896)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1645)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1264)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:322)
      at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.instantiateUsingSerialization(PureJavaReflectionProvider.java:91)
      ... 21 more

        People

        • Assignee:
          Unassigned
          Reporter:
          German
        • Votes:
          0 Vote for this issue
          Watchers:
          1 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: