-
Bug
-
Resolution: Fixed
-
P3
-
5.0, 5.0u14
-
b07
-
generic, x86
-
generic, linux
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2200852 | 7 | Robert Mckenna | P2 | Resolved | Fixed | b120 |
JDK-2173290 | 6u14 | Ken Cavanaugh | P3 | Resolved | Fixed | b02 |
JDK-2174419 | 5.0u19 | Robert Mckenna | P3 | Resolved | Fixed | b01 |
JDK-2171591 | 5.0u17-rev | Robert Mckenna | P3 | Resolved | Fixed | b10 |
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode)
A DESCRIPTION OF THE PROBLEM :
When Enums are passed over RMI IIOP, they are not serialized/deserialized correctly.
They fail the equals() test. This is quite major.
I have an application that serializes an enumeration across a socket connection. When I read one and do an equals against one of the local Enum objects, it fails. However, enum.name().equals(deserializedEnum.name()) returns true and so does enum.getClass().equals(deserializedEnum.name()).
I am doing an import static com.foo.bar.MyEnum.* when I set my items to be serialized, I don't know if that causes a problem or not.
However, I can't reproduce the error simply. Creating a local ByteArrayOutput/Input streams works ok. This seems to be happening over a socket connection.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac EnumIIOPBreakage.java
rmic -classpath . -iiop Server
java -classpath . EnumIIOPBreakage
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
equal? true
classes equal? true
names equal? true
ACTUAL -
equal? false
classes equal? true
names equal? true
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.rmi.*;
import java.util.*;
import javax.rmi.*;
import javax.naming.*;
enum MyEnum { ONE, TWO, THREE };
public class EnumIIOPBreakage
{
public static void main(String[] args)
throws Throwable
{
Hashtable properties = new Hashtable();
properties.put("java.naming.factory.initial",
"com.sun.jndi.cosnaming.CNCtxFactory");
properties.put("java.naming.provider.url", "iiop://localhost:1099");
new Server(properties);
Context context = new InitialContext(properties);
Object ref = context.lookup("server");
RServer server = (RServer) PortableRemoteObject.narrow(ref, RServer.class);
System.out.println("equal? " +
MyEnum.ONE.equals(server.get(MyEnum.ONE.name())));
System.out.println("classes equal? " +
MyEnum.ONE.getClass().equals(
server.get(MyEnum.ONE.name()).getClass()));
System.out.println("names equal? " +
MyEnum.ONE.name().equals(
server.get(MyEnum.ONE.name()).name()));
}
}
class Server
implements RServer
{
public Server(Hashtable properties)
throws Throwable
{
PortableRemoteObject.exportObject(this);
Context context = new InitialContext(properties);
context.rebind("server", this);
}
public MyEnum get(String name)
{
return MyEnum.valueOf(name);
}
}
interface RServer
extends Remote
{
MyEnum get(String name)
throws RemoteException;
}
---------- END SOURCE ----------
###@###.### 2005-05-30 05:28:17 GMT
- backported by
-
JDK-2200852 Serialization of Enums over IIOP is broke.
- Resolved
-
JDK-2171591 Serialization of Enums over IIOP is broke.
- Resolved
-
JDK-2173290 Serialization of Enums over IIOP is broke.
- Resolved
-
JDK-2174419 Serialization of Enums over IIOP is broke.
- Resolved
- relates to
-
JDK-6877056 SVUID calculated for java.lang.Enum is not 0L
- Closed
-
JDK-6421053 Enum hashCode is order dependent
- Closed
-
JDK-6988478 Enum Serialization over IIOP is broken
- Closed
-
JDK-6993483 Documentation improvement for enum constants used over RMI-IIOP.
- Closed