United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7046882 Regression : Enum exchanged as parameters using CORBA call results in Exception
JDK-7046882 : Regression : Enum exchanged as parameters using CORBA call results in Exception

Details
Type:
Bug
Submit Date:
2011-05-20
Status:
Resolved
Updated Date:
2011-08-19
Project Name:
JDK
Resolved Date:
2011-06-03
Component:
other-libs
OS:
windows
Sub-Component:
corba:idl
CPU:
generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Backport:
Backport:
Backport:
Backport:
Relates:

Sub Tasks

Description
REGRESSION
----------
This bug report starts with JDK 7b123.  This appears to be a regression from
CR 6877056, which was fixed in JDK 7 b123.  The regression also begins with
JDK 6u19 and CR 6877056 was delivered in JDK 6u19.

SYNOPSIS
--------
Enum exchanged as parameters using CORBA call results in Exception

OPERATING SYSTEM
----------------
Windows XP

FULL JDK VERSION
----------------
JDK 7 from b123 onwards
Java 6 from 6u19 onwards

PROBLEM DESCRIPTION
-------------------
When the enum class 'java.math.RoundingMode' is used as parameter in a remote method and tried to send across to other side using CORBA call, the call fails with an Exception.


REPRODUCTION INSTRUCTIONS
-------------------------
1.Compile the test
   a) javac EnumTest.java
   b) rmic -iiop EnumTest$ServiceImpl

2.Run the command
        java EnumTest

Expected result:
        Test should pass without throwing exceptions

Observed result:
        Exceptions as detailed below:

WARNING: "IOP00810211: (MARSHAL) Exception from readValue on ValueHandler in CDRInputStream"
org.omg.CORBA.MARSHAL:   vmcid: SUN  minor code: 211 completed: Maybe
        at com.sun.corba.se.impl.logging.ORBUtilSystemException.valuehandlerReadException(ORBUtilSystemException.java:6528)
        at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1061)
        at com.sun.corba.se.impl.encoding.CDRInputStream.read_value(CDRInputStream.java:271)
        at InitialContextCloseCleanupTest$_ServiceImpl_Tie.doit(InitialContextCloseCleanupTest$_ServiceImpl_Tie.java:84)
        at InitialContextCloseCleanupTest$_ServiceImpl_Tie._invoke(InitialContextCloseCleanupTest$_ServiceImpl_Tie.java:73)
        at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:653)
        at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:205)
        at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1698)
        at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1558)
        at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:940)
        at com.sun.corba.se.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:198)
        at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:712)
        at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOrChannelConnectionImpl.java:469)
        at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.doWork(SocketOrChannelConnectionImpl.java:1230)
        at com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:418)
Caused by: java.lang.IllegalArgumentException
        at java.nio.Buffer.position(Buffer.java:236)
        at com.sun.corba.se.impl.encoding.ByteBufferWithInfo.position(ByteBufferWithInfo.java:176)
        at com.sun.corba.se.impl.encoding.CDRInputStream_1_2.alignAndCheck(CDRInputStream_1_2.java:95)
        at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_long(CDRInputStream_1_0.java:494)
        at com.sun.corba.se.impl.encoding.CDRInputStream.read_long(CDRInputStream.java:151)
        at com.sun.corba.se.impl.io.IIOPInputStream.inputObject(IIOPInputStream.java:1016)
        at com.sun.corba.se.impl.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:416)
        at com.sun.corba.se.impl.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:333)
        at com.sun.corba.se.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:299)
        at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1050)
        ... 13 more

Exception in thread "main" java.rmi.MarshalException: CORBA MARSHAL 1398079699 Maybe; nested exception is:
        org.omg.CORBA.MARSHAL: ----------BEGIN server-side stack trace----------

org.omg.CORBA.MARSHAL:   vmcid: SUN  minor code: 211 completed: Maybe
        at com.sun.corba.se.impl.logging.ORBUtilSystemException.valuehandlerReadException(ORBUtilSystemException.java:6528)
        at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1061)
        at com.sun.corba.se.impl.encoding.CDRInputStream.read_value(CDRInputStream.java:271)
        at InitialContextCloseCleanupTest$_ServiceImpl_Tie.doit(InitialContextCloseCleanupTest$_ServiceImpl_Tie.java:84)
        at InitialContextCloseCleanupTest$_ServiceImpl_Tie._invoke(InitialContextCloseCleanupTest$_ServiceImpl_Tie.java:73)
        at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:653)
        at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:205)
        at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1698)
        at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1558)
        at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:940)
        at com.sun.corba.se.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:198)
        at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:712)
        at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOrChannelConnectionImpl.java:469)
        at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.doWork(SocketOrChannelConnectionImpl.java:1230)
        at com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:418)
Caused by: java.lang.IllegalArgumentException
        at java.nio.Buffer.position(Buffer.java:236)
        at com.sun.corba.se.impl.encoding.ByteBufferWithInfo.position(ByteBufferWithInfo.java:176)
        at com.sun.corba.se.impl.encoding.CDRInputStream_1_2.alignAndCheck(CDRInputStream_1_2.java:95)
        at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_long(CDRInputStream_1_0.java:494)
        at com.sun.corba.se.impl.encoding.CDRInputStream.read_long(CDRInputStream.java:151)
        at com.sun.corba.se.impl.io.IIOPInputStream.inputObject(IIOPInputStream.java:1016)
        at com.sun.corba.se.impl.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:416)
        at com.sun.corba.se.impl.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:333)
        at com.sun.corba.se.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:299)
        at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1050)
        ... 13 more

----------END server-side stack trace----------  vmcid: SUN  minor code: 211 completed: Maybe
        at com.sun.corba.se.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:213)
        at javax.rmi.CORBA.Util.mapSystemException(Util.java:83)
        at InitialContextCloseCleanupTest$_Service_Stub.doit(InitialContextCloseCleanupTest$_Service_Stub.java:49)
        at InitialContextCloseCleanupTest.main(InitialContextCloseCleanupTest.java:44)
Caused by: org.omg.CORBA.MARSHAL: ----------BEGIN server-side stack trace----------
org.omg.CORBA.MARSHAL:   vmcid: SUN  minor code: 211 completed: Maybe
        at com.sun.corba.se.impl.logging.ORBUtilSystemException.valuehandlerReadException(ORBUtilSystemException.java:6528)
        at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1061)
        at com.sun.corba.se.impl.encoding.CDRInputStream.read_value(CDRInputStream.java:271)
        at InitialContextCloseCleanupTest$_ServiceImpl_Tie.doit(InitialContextCloseCleanupTest$_ServiceImpl_Tie.java:84)
        at InitialContextCloseCleanupTest$_ServiceImpl_Tie._invoke(InitialContextCloseCleanupTest$_ServiceImpl_Tie.java:73)
        at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:653)
        at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:205)
        at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1698)
        at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1558)
        at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:940)
        at com.sun.corba.se.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:198)
        at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:712)
        at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOrChannelConnectionImpl.java:469)
        at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.doWork(SocketOrChannelConnectionImpl.java:1230)
        at com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:418)
Caused by: java.lang.IllegalArgumentException
        at java.nio.Buffer.position(Buffer.java:236)
        at com.sun.corba.se.impl.encoding.ByteBufferWithInfo.position(ByteBufferWithInfo.java:176)
        at com.sun.corba.se.impl.encoding.CDRInputStream_1_2.alignAndCheck(CDRInputStream_1_2.java:95)
        at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_long(CDRInputStream_1_0.java:494)
        at com.sun.corba.se.impl.encoding.CDRInputStream.read_long(CDRInputStream.java:151)
        at com.sun.corba.se.impl.io.IIOPInputStream.inputObject(IIOPInputStream.java:1016)
        at com.sun.corba.se.impl.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:416)
        at com.sun.corba.se.impl.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:333)
        at com.sun.corba.se.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:299)
        at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1050)
        ... 13 more

----------END server-side stack trace----------  vmcid: SUN  minor code: 211 completed: Maybe
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
        at com.sun.corba.se.impl.protocol.giopmsgheaders.MessageBase.getSystemException(MessageBase.java:919)
        at com.sun.corba.se.impl.protocol.giopmsgheaders.ReplyMessage_1_2.getSystemException(ReplyMessage_1_2.java:116)
        at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.getSystemExceptionReply(CorbaMessageMediatorImpl.java:590)
        at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.processResponse(CorbaClientRequestDispatcherImpl.java:469)
        at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete(CorbaClientRequestDispatcherImpl.java:353)
        at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.invoke(CorbaClientDelegateImpl.java:147)
        at org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:475)
        at InitialContextCloseCleanupTest$_Service_Stub.doit(InitialContextCloseCleanupTest$_Service_Stub.java:39)
        ... 1 more

TESTCASE SOURCE
---------------
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import java.io.*;
import java.util.*;
import org.omg.CORBA.ORB;
import javax.rmi.CORBA.Tie;
import javax.rmi.CORBA.Util;

/*
* NB: To run the test successfully, the IIOP stubs and ties need to have been
*     created for EnumTest.ServiceImpl, using 'rmic -iiop'.
*/
public class EnumTest {
    public static void main(String[] args) throws Exception {
        ORB serverORB = ORB.init(args, null);
        ServiceImpl impl = new ServiceImpl();
        Tie tie = Util.getTie(impl);
        org.omg.CORBA.Object obj = tie.thisObject();
        serverORB.connect(obj);
        String ior = serverORB.object_to_string(obj);
        System.out.println("Server Started..");

        ORB clientORB = ORB.init(args, null);
        org.omg.CORBA.Object clientObj = clientORB.string_to_object(ior);
        Service remoteObj =(Service)PortableRemoteObject.narrow(clientObj,
                                                                Service.class);
        System.out.println("Client started.. Sending requests#");
        java.math.RoundingMode rm1 =java.math.RoundingMode.valueOf(7);
        java.math.RoundingMode rm2 = remoteObj.doit( rm1 );
        System.out.println("RM="+rm1.compareTo(rm2));

    }

    interface Service extends Remote {
        java.math.RoundingMode doit(java.math.RoundingMode rm) throws RemoteException;
    }

    static class ServiceImpl extends PortableRemoteObject implements Service {
        public ServiceImpl() throws RemoteException {
        }

        public java.math.RoundingMode doit(java.math.RoundingMode rm) {
            System.out.println("received and returning # " + rm);
            return rm;
        }
    }
}

                                    

Comments
EVALUATION

Based on code review:
com.sun.corba.se.impl.io.IIOPOutputStream
com.sun.corba.se.impl.io.IIOPInputStream
com.sun.corba.se.impl.encoding.CDRInputStream_1_0.java
com.sun.corba.se.impl.encoding.CDROutputStream_1_0.java
looks like the JDK approach to handling enums is to simply
marshal them, and then use "receiver makes right".  
That's why the use of NO_FIELDS as a value of fields variable
in com.sun.corba.se.impl.io.ObjectStreamClass.java 
instead of setting
fields = new ObjectStreamField[numFields];
is incorrect.
                                     
2011-05-24
SUGGESTED FIX

http://jpsesvr.sfbay.sun.com:8080/ctetools/html/ViewDetail.jsp?index=4097
                                     
2011-05-25



Hardware and Software, Engineered to Work Together