XStream
  1. XStream
  2. XSTR-202

Incompatibility between Sun Java 1.5 and 1.4.2

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • JDK version and platform:
      Sun Java 1.5/1.4.2 on Windows and Linux

      Description

      I don't know if it's really a bug, but we encountered some incompatibilities between Java 1.4.2 and Java 1.5 using xstream-1.1 (using the PureJavaReflectionProvider).

      We are using xml-messages (generated by xstream) to communicate between a server and numerous clients. The server is running on Suns JVM 1.4.2 while some of the clients have upgraded to Java 1.5 in the meantime.

      We are serializing an Object having a member of the type List. this member is initialized with:
      member = Collections.synchronizedList( new ArrayList());

      If we serialize that class on 1.4.2, it cannot be deserialized on 1.5.
      The other way around it is also not possible to deserialize the xml code generated on 1.4.2.

      It seems to have something to do with renamings of internal classes:
      1.4.2: java.util.Collections$SynchronizedRandomAccessList
      1.5.0: java.util.collections$SynchronizedList

      With the two classes appended to the end of that message, the error can easily be reproduced.

      It whould be nice if somebody of you can give me a feedback concerning the problem. One solution for us may be to use a Vector instead of a List, but this would be hard to realize because every client running a non-up-to-date version would be unable to use our software...

      thank you,
      Andreas Wetzel

      // start XStreamTest.java
      public class XStreamTest
      {
      private XStream myXStream;

      public XStreamTest()

      { myXStream = new XStream( new PureJavaReflectionProvider(), new DomDriver()); }

      private void writeXML()

      { System.out.println( myXStream.toXML( new ResultSet())); }

      private void readXML( File f) throws FileNotFoundException

      { FileReader reader = new FileReader( f); ResultSet set = (ResultSet) myXStream.fromXML( reader); System.out.println( set.toString()); }

      public static void main( String[] args)
      {
      XStreamTest test = new XStreamTest();

      if ( args.length == 1 ) {
      File f = new File( args[0]);
      if ( f.exists() ) {
      try

      { test.readXML( f); return; }

      catch( FileNotFoundException e) {
      }
      }
      }
      test.writeXML();
      }
      }
      // end XStreamTest.java

      // start ResultSet.java
      public class ResultSet
      {
      List results;

      public ResultSet()

      { results = Collections.synchronizedList( new ArrayList()); results.add( "foo"); results.add( "bar"); }

      public String toString()
      {
      StringBuffer buffer = new StringBuffer();
      for (Iterator it = results.iterator(); it.hasNext()

      { buffer.append( (String) it.next()).append( "\n"); }

      return buffer.toString();
      }
      }
      // end ResultSet.java

        People

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

          Dates

          • Created:
            Updated: