public inbox for java-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug java/20169] New: Serialization: readResolve does not work
@ 2005-02-23 16:06 bonniot at users dot sf dot net
  2005-02-23 16:38 ` [Bug libgcj/20169] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: bonniot at users dot sf dot net @ 2005-02-23 16:06 UTC (permalink / raw)
  To: java-prs

I attach a simple Java class, which exercises the readResolve method. An object
is serialzed and deserialized from a byte array. Because of the readResolve
method, the object read back should be the exact same instance. This works with
JDK, but fails with both gij and gcj, as of today. It also fails with other free
runtimes: kaffe (1.1.4.PRECVS8) and jamvm (1.2.3), so it could be a GNU
classpath issue.

Here is the testcase:
///////////////////////////////////

import java.io.*;

public abstract class Enum implements Serializable
{
  static Enum instance;

  Object readResolve() {
    return instance;
  }

  static class Color extends Enum
  {
    static final Color red = new Color();

    static { instance = red; }
  }

  public static void main(String[] args)
  {
    try {
      ByteArrayOutputStream outb = new ByteArrayOutputStream();
      ObjectOutputStream outs = new ObjectOutputStream(outb);
      outs.writeObject(Color.red);
      byte[] store = outb.toByteArray();

      ByteArrayInputStream inb = new ByteArrayInputStream(store);
      ObjectInputStream ins = new ObjectInputStream(inb);

      Color color = (Color) ins.readObject();
      System.out.println(color);
      System.out.println(Color.red);
      System.out.println(color == Color.red);
    }
    catch (Throwable e) {
      throw new Error(e);
    }
  }
}
//////////////////////////////////////

Here is what happens:

/tmp/gcc/bin/gcj -C Enum.java

#### JDK: java Enum
Enum$Color@1cfb549
Enum$Color@1cfb549
true

#### GIJ: LD_LIBRARY_PATH=/tmp/gcc/lib /tmp/gcc/bin/gij Enum
Enum$Color@58c78
Enum$Color@58eb8
false

#### GCJ: /tmp/gcc/bin/gcj --main=Enum *.class
LD_LIBRARY_PATH=/tmp/gcc/lib ./a.out
Enum$Color@58cd0
Enum$Color@58f20
false
/tmp/gcc/bin/gcj --version
gcj (GCC) 4.0.0 20050223 (experimental)

-- 
           Summary: Serialization: readResolve does not work
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bonniot at users dot sf dot net
                CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
                    dot org
  GCC host triplet: i386-debian-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20169


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/20169] Serialization: readResolve does not work
  2005-02-23 16:06 [Bug java/20169] New: Serialization: readResolve does not work bonniot at users dot sf dot net
@ 2005-02-23 16:38 ` pinskia at gcc dot gnu dot org
  2005-02-28 13:08 ` bonniot at users dot sf dot net
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-23 16:38 UTC (permalink / raw)
  To: java-prs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|java                        |libgcj


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20169


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/20169] Serialization: readResolve does not work
  2005-02-23 16:06 [Bug java/20169] New: Serialization: readResolve does not work bonniot at users dot sf dot net
  2005-02-23 16:38 ` [Bug libgcj/20169] " pinskia at gcc dot gnu dot org
@ 2005-02-28 13:08 ` bonniot at users dot sf dot net
  2005-03-03  2:51 ` bonniot at users dot sf dot net
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bonniot at users dot sf dot net @ 2005-02-28 13:08 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From bonniot at users dot sf dot net  2005-02-26 01:35 -------
After some investigation, I think I understand what is going wrong. It seems
like readResolve is only called if it is declared in the deserialized object's
class. However, it should also be searched for in the classes's parents,
provided the method there is visible (that is, normal rules apply).

I submitted a related testcase to mauve:
http://sources.redhat.com/ml/mauve-patches/2005/msg00032.html

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20169


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/20169] Serialization: readResolve does not work
  2005-02-23 16:06 [Bug java/20169] New: Serialization: readResolve does not work bonniot at users dot sf dot net
  2005-02-23 16:38 ` [Bug libgcj/20169] " pinskia at gcc dot gnu dot org
  2005-02-28 13:08 ` bonniot at users dot sf dot net
@ 2005-03-03  2:51 ` bonniot at users dot sf dot net
  2005-05-27  1:04 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bonniot at users dot sf dot net @ 2005-03-03  2:51 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From bonniot at users dot sf dot net  2005-03-02 22:11 -------
Submitting the mauve testcases, with a classpath patch on the way.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20169


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/20169] Serialization: readResolve does not work
  2005-02-23 16:06 [Bug java/20169] New: Serialization: readResolve does not work bonniot at users dot sf dot net
                   ` (2 preceding siblings ...)
  2005-03-03  2:51 ` bonniot at users dot sf dot net
@ 2005-05-27  1:04 ` pinskia at gcc dot gnu dot org
  2005-05-27  9:47 ` bonniot at users dot sf dot net
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-27  1:04 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-05-27 01:04 -------
Hmm, I get:
Exception in thread "main" java.lang.Error: java.lang.ClassNotFoundException: Enum$Color
   at Enum.main (Enum.java:34)
Caused by: java.lang.ClassNotFoundException: Enum$Color
   at java.lang.Class.forName (natClass.cc:91)
   at java.io.ObjectInputStream.resolveClass (ObjectInputStream.java:782)
   at java.io.ObjectInputStream.readClassDescriptor (ObjectInputStream.java:534)
   at java.io.ObjectInputStream.readObject (ObjectInputStream.java:228)
   at java.io.ObjectInputStream.readObject (ObjectInputStream.java:275)
   at Enum.main (Enum.java:29)

Which looks like a different bug.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20169


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/20169] Serialization: readResolve does not work
  2005-02-23 16:06 [Bug java/20169] New: Serialization: readResolve does not work bonniot at users dot sf dot net
                   ` (3 preceding siblings ...)
  2005-05-27  1:04 ` pinskia at gcc dot gnu dot org
@ 2005-05-27  9:47 ` bonniot at users dot sf dot net
  2005-05-27 15:05 ` bonniot at users dot sf dot net
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bonniot at users dot sf dot net @ 2005-05-27  9:47 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From bonniot at users dot sf dot net  2005-05-27 09:47 -------
FYI, my patch for solving this bug in classpath is
https://savannah.gnu.org/patch/index.php?func=detailitem&item_id=3893
My copyright assignment is on its way...

I cannot comment on the current behaviour of gcc, as my nightly build seems borked.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20169


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/20169] Serialization: readResolve does not work
  2005-02-23 16:06 [Bug java/20169] New: Serialization: readResolve does not work bonniot at users dot sf dot net
                   ` (4 preceding siblings ...)
  2005-05-27  9:47 ` bonniot at users dot sf dot net
@ 2005-05-27 15:05 ` bonniot at users dot sf dot net
  2005-06-01 20:01 ` tromey at gcc dot gnu dot org
  2005-07-24 19:36 ` tromey at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: bonniot at users dot sf dot net @ 2005-05-27 15:05 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From bonniot at users dot sf dot net  2005-05-27 15:05 -------
The new behaviour is caused by PR21785, which currently masks this bug.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |21785


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20169


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/20169] Serialization: readResolve does not work
  2005-02-23 16:06 [Bug java/20169] New: Serialization: readResolve does not work bonniot at users dot sf dot net
                   ` (5 preceding siblings ...)
  2005-05-27 15:05 ` bonniot at users dot sf dot net
@ 2005-06-01 20:01 ` tromey at gcc dot gnu dot org
  2005-07-24 19:36 ` tromey at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at gcc dot gnu dot org @ 2005-06-01 20:01 UTC (permalink / raw)
  To: java-prs



-- 
Bug 20169 depends on bug 21785, which changed state.

Bug 21785 Summary: [4.1 regression] ClassNotFound during deserialization
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21785

           What    |Old Value                   |New Value
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
             Status|NEW                         |ASSIGNED
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20169


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/20169] Serialization: readResolve does not work
  2005-02-23 16:06 [Bug java/20169] New: Serialization: readResolve does not work bonniot at users dot sf dot net
                   ` (6 preceding siblings ...)
  2005-06-01 20:01 ` tromey at gcc dot gnu dot org
@ 2005-07-24 19:36 ` tromey at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at gcc dot gnu dot org @ 2005-07-24 19:36 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From tromey at gcc dot gnu dot org  2005-07-24 19:36 -------
Note that this is fixed in Classpath but not in libgcj as
we still have divergences in serialization.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-07-24 19:36:35
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20169


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2005-07-24 19:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-23 16:06 [Bug java/20169] New: Serialization: readResolve does not work bonniot at users dot sf dot net
2005-02-23 16:38 ` [Bug libgcj/20169] " pinskia at gcc dot gnu dot org
2005-02-28 13:08 ` bonniot at users dot sf dot net
2005-03-03  2:51 ` bonniot at users dot sf dot net
2005-05-27  1:04 ` pinskia at gcc dot gnu dot org
2005-05-27  9:47 ` bonniot at users dot sf dot net
2005-05-27 15:05 ` bonniot at users dot sf dot net
2005-06-01 20:01 ` tromey at gcc dot gnu dot org
2005-07-24 19:36 ` tromey at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).