Bug 201712 - GCJ: (de)serialization of Locale objects within an ObjectArray does not work properly
Summary: GCJ: (de)serialization of Locale objects within an ObjectArray does not work ...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: rawhide
Hardware: i386
OS: Linux
medium
high
Target Milestone: ---
Assignee: Tom Tromey
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-08-08 14:07 UTC by IBM Bug Proxy
Modified: 2014-08-11 05:46 UTC (History)
3 users (show)

Fixed In Version: fc6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2007-03-08 23:54:01 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description IBM Bug Proxy 2006-08-08 14:07:44 UTC
LTC Owner is: TAPHORN.com
LTC Originator is: TAPHORN.com


Problem description:

When an Object Array (Object[]) is created which contains several different
Objects like e.g. another Object[], a Long objetc and an object of type Locale,
the serialization of the Object[] into a file seems to work correctly. Once the
serialized Object[] gets deserialized again, the following exception is thrown:

Exception in thread "main" java.io.IOException: Unknown marker on stream: 4
   at java.io.ObjectInputStream.readObject(libgcj.so.7rh)
   at java.io.ObjectInputStream.readArrayElements(libgcj.so.7rh)
   at java.io.ObjectInputStream.readObject(libgcj.so.7rh)
   at java.io.ObjectInputStream.readArrayElements(libgcj.so.7rh)
   at java.io.ObjectInputStream.readObject(libgcj.so.7rh)
   at SerializationTest.main(SerializationTest.java:65)

For (de)serialization we used the ObjectOutputStream and 
ObjectInputStream.


Hardware/Software Environment
uname -a shows:
Linux localhost 2.6.17-1.2157_FC5 #1 Tue Jul 11 22:55:46 EDT 2006 i686 i686 i386
GNU/Linux

  We are running the FC rawhide (last update: Aug,4th) on an i386 Intel machine.

  rpm -qa|grep gcj
   libgcj-4.1.1-14
   libgcj-src-4.1.1-14
   libgcj-devel-4.1.1-14
   java-1.4.2-gcj-compat-devel-1.4.2.0-40jpp_100rh
   java-1.4.2-gcj-compat-1.4.2.0-40jpp_100rh
   java-1.4.2-gcj-compat-javadoc-1.4.2.0-40jpp_100rh
   java-1.4.2-gcj-compat-src-1.4.2.0-40jpp_100rh


Please provide contact information if the submitter is not the primary contact.
  Initially the problem was reported by Michael Bauschert
<Michael.Bauschert[at]de.ibm.com> who is able to give further information on
this problem.


Is this reproducible?
  Yes.
  Save the code added at the bottom of this bugzila into a file named
'SerializationTest.java', and perform the following steps:
    1. gcj -C SerializationTest.java
    2. java -cp . SerializationTest sample
    3. The error should be displayed.

Is the system (not just the application) hung?
  No


Did the system produce an OOPS message on the console?
  No


Is the system sitting in a debugger right now?
  No


Additional information:
Here is a sample code which reproduces the error:
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;

public class SerializationTest {

        public static void main(String[] args) throws Exception {
                if (args.length != 1)
                {
                        System.err.println("Usage: java -cp . SerializationTest
filename");
                        return;
                }

                ObjectOutputStream out = new ObjectOutputStream(new
FileOutputStream(args[0]));


                Object[] fiveElementArray = new Object[5];
                fiveElementArray[0] = new Object[7];
                fiveElementArray[1] = Locale.UK;
                fiveElementArray[4] = new Long(0);

                Object[] in1 = new Object[3];
                in1[0] = fiveElementArray;
                out.writeObject(in1);

                HashSet hashSet = new HashSet();
                hashSet.add("Test1");
                hashSet.add(hashSet);
                out.writeObject(hashSet);

                out.flush();
                out.close();

                ObjectInputStream in = new ObjectInputStream(new
FileInputStream(args[0]));

                Object o1 = in.readObject();
                System.out.println("Object #1 " + o1);

                Object o2 = in.readObject();
                System.out.println("Object #2 " + o2);

        }
}

An additional comment here:
The sample code works properly while using a SUN or IBM JVM.

Comment 1 Anthony Green 2006-08-18 14:03:15 UTC
tromey: I'm guessing that this is fixed by...

http://developer.classpath.org/pipermail/classpath-patches/2006-August/003824.html



Comment 2 IBM Bug Proxy 2006-08-30 15:01:01 UTC
----- Additional Comments From TAPHORN.com  2006-08-30 10:56 EDT -------
Well this problem seems not to be fixed...

[root@localhost ~]# java -version
java version "1.4.2"
gij (GNU libgcj) version 4.1.1 20060828 (Red Hat 4.1.1-20)

Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


[root@localhost ~]# java -cp . SerializationTest sample
Exception in thread "main" java.io.IOException: Unknown marker on stream: 4
   at java.io.ObjectInputStream.readObject(libgcj.so.7rh)
   at java.io.ObjectInputStream.readArrayElements(libgcj.so.7rh)
   at java.io.ObjectInputStream.readObject(libgcj.so.7rh)
   at java.io.ObjectInputStream.readArrayElements(libgcj.so.7rh)
   at java.io.ObjectInputStream.readObject(libgcj.so.7rh)
   at SerializationTest.main(SerializationTest.java:65) 

Comment 3 Tom Tromey 2006-09-26 23:35:02 UTC
Anthony -- thanks for the heads up.  I am testing a similar patch now.

Glen -- that patch went into Classpath, but not libgcj (yet).
If this is the problem I will put in a new patch.
Either way, I will update this PR with what I find.


Comment 4 Tom Tromey 2006-09-27 08:01:19 UTC
Anthony was correct, that bug fix did point out the problem.
I checked in a different patch to gcc svn trunk and the
Red Hat 4.1 branch; it is revision 117249 on the branch.


Comment 5 IBM Bug Proxy 2006-10-04 15:06:12 UTC
----- Additional Comments From TAPHORN.com  2006-10-04 11:00 EDT -------
Sorry for the latency, I was on vacation...

With the current state of FC6 (RawHide of FC), the sample added to this bugzilla
works properly. The level which was used for testing is:

[root@localhost ~]# java -version
java version "1.4.2"
gij (GNU libgcj) version 4.1.1 20060928 (Red Hat 4.1.1-28)

Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 

Comment 6 Tom Tromey 2007-03-08 23:54:01 UTC
I'm closing this, since it was fixed in FC6.



Note You need to log in before you can comment on or make changes to this bug.