Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4143260

IDL Compiled with portable flag doesn't work

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.2.0
    • other-libs
    • sparc
    • solaris_2.6



      Name: rm29839 Date: 05/27/98


      The following works fine when the IDL compiler is
      used with the -fno-portable flag. Otherwise I get
      a marshalling error. Launch the name service,
      then launch the receiver, then launch the sender.
      When the sender tries to send a Data instance, a
      marshalling error occurs. Note that the getName
      method of the receiver works fine. It's the Data
      transfer that doesn't work.

      Here's the IDL:

         struct Data {
            string name;
            long a, b, c, d, e, f, g, h, i;
         };


         interface Receiver {
            string getName();
            void receiveData(in Data val);
         };


      Here's the ReceiverImpl.java code:

      import java.util.Properties;
      import org.omg.CORBA.Any;
      import org.omg.CORBA.ORB;
      import org.omg.CosNaming.*;


      public class ReceiverImpl extends _ReceiverImplBase {

         public ReceiverImpl() { }

         public String getName() {
            System.out.println("I'm Daffy.");
            return "Daffy Duck";
         }

         public void receiveData(Data d) {
            System.out.println("Receiver received data");
            System.out.println(" " + d.name + " " + d.a + " " + d.b + " " + d.c +
                                                " " + d.d + " " + d.e + " " + d.f +
                                                " " + d.g + " " + d.h + " " + d.i);

            System.out.println("Receiver extracted data");
         }

         public static void main(String args[]) {

            Properties props = new Properties();
            props.put("org.omg.CORBA.ORBInitialPort", Sender.PortNumber);
            ORB orb = ORB.init(args, props);

            ReceiverImpl r = new ReceiverImpl();
            orb.connect(r);
            bind(r, orb);

            hangOut();
         }

         public static void hangOut() {
            // Now just hang out.
            //
            java.lang.Object sync = new java.lang.Object();
            synchronized (sync) {
               try {
                  sync.wait();
               } catch (InterruptedException e) {
                  System.err.println("Server interrupted.");
               }
            }
         }

         public static void bind(ReceiverImpl r, ORB orb) {
            // Now try to register with the name server.
            //
            org.omg.CORBA.Object wideNSRef = null;

            try {
               wideNSRef = orb.resolve_initial_references("NameService");
            } catch (Exception e) {
               System.out.println("Cannot find the CORBA Name Service");
               System.exit(1);
            }

            NamingContext namingContext = NamingContextHelper.narrow(wideNSRef);
            NameComponent serverNC = new NameComponent(Sender.ServerName, "");

            NameComponent[] path = {serverNC};

            try {
               namingContext.rebind(path, r);
            } catch (Exception e) {
               // could be a number of exceptions here from CosNaming
               // InvalidName, CannotProceed, NotFound
               //
               System.err.println("Cannot bind server in name server:\n" + e);
               System.exit(1);
            }

         }

      }



      Here is the Sender.java code:

      import java.util.Properties;

      import org.omg.CORBA.ORB;
      import org.omg.CosNaming.*;

      public class Sender {

         final public static String ServerName = "DaffyFactory";
         final public static String PortNumber = "1050";




         //////////////////////////////////////////////////////////////////////
         // Main Method
         //////////////////////////////////////////////////////////////////////

         public static void main(String args[]) {
            Properties props = new Properties();
            props.put("org.omg.CORBA.ORBInitialPort", PortNumber);
            ORB orb = ORB.init(args, props);
            Data d = new Data("DDD", 1, 2, 3, 4, 5, 6, 7, 8, 9);

            Receiver receiver = getReceiver(orb);
            System.out.println("Receiver is " + receiver.getName());

            System.out.print("Sender sending data:");
            System.out.println(" " + d.name + " " + d.a + " " + d.b + " " + d.c +
                                                " " + d.d + " " + d.e + " " + d.f +
                                                " " + d.g + " " + d.h + " " + d.i);
            receiver.receiveData(d);
         }


         static Receiver getReceiver(ORB orb) {
            org.omg.CORBA.Object wideNSRef = null;
            Receiver f = null;

            try {
               wideNSRef = orb.resolve_initial_references("NameService");
            } catch (Exception e) {
               System.out.println("Cannot find the CORBA Name Service");
               System.exit(1);
            }

            NamingContext namingContext = NamingContextHelper.narrow(wideNSRef);
            NameComponent senderNC = new NameComponent(ServerName, "");
            NameComponent[] path = {senderNC};

            try {
               f = ReceiverHelper.narrow( namingContext.resolve(path) );
            } catch (Exception e) {
               System.out.println("Cannot bind to " + ServerName);
               System.out.println(e);
               System.exit(1);
            }

            return f;
         }

      }


      Here is execution:

      Receiver output:

      I'm Daffy.



      Sender output:

      Receiver is Daffy Duck
      Sender sending data: DDD 1 2 3 4 5 6 7 8 9
      org.omg.CORBA.MARSHAL: minor code: 0 completed: No
              at java.lang.Class.newInstance(Native Method)
              at com.sun.CORBA.iiop.ReplyMessage.getSystemException(ReplyMessage.java:73)
              at com.sun.CORBA.iiop.Generic.invoke(Generic.java:137)
              at com.sun.CORBA.iiop.RequestImpl.doInvocation(RequestImpl.java:352)
              at com.sun.CORBA.iiop.RequestImpl.invoke(RequestImpl.java:216)
              at _ReceiverStub.receiveData(_ReceiverStub.java:40)
              at Sender.main(Sender.java:31)
      (Review ID: 30478)
      ======================================================================

            Unassigned Unassigned
            rmandelsunw Ronan Mandel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: