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

TypeCodes don't correctly handle wchars in Anys

XMLWordPrintable

    • generic
    • generic

      The wchar handling code is commented out in TypeCodeImpl.

      Also, there is no minor code associated with an unknown tk int.

      Sample code:

      module event
      {
          enum EventType
          {
              metric_created,
              metric_changed,
              metric_deleted,
              metric_error
          };

          struct MetricEvent {
              EventType type;
              wstring metric;
              wchar testa;
              wchar testb;
          };

          interface Logger {
              void process_event(in any ev);
          };
      };

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

      public class Client
      {

          public static void main(String args[])
          {
      try{
      ORB orb = ORB.init(args, System.getProperties());

                  System.out.println("Unicode 3044 is: " + '\u3044');

                  // get the root naming context
                  org.omg.CORBA.Object objRef =
      orb.resolve_initial_references("NameService");
                  NamingContext ncRef = NamingContextHelper.narrow(objRef);
       
                  // resolve the Object Reference in Naming
                  NameComponent nc = new NameComponent("testref", "");
                  NameComponent path[] = {nc};
                  Logger loggerRef = LoggerHelper.narrow(ncRef.resolve(path));

      // call the hello server object and print results
                  Any any = orb.create_any();

                  String name = "\u3044\u3048";

                  MetricEventHelper.insert(any, new MetricEvent(EventType.metric_created,
                                                                name,
                                                                '\u3044',
                                                                '\u3048'));

                  loggerRef.process_event(any);

      } catch (Exception e) {
      e.printStackTrace();
      }
          }
      }

      import event.*;
      import org.omg.CORBA.*;
      import org.omg.CosNaming.*;
      import org.omg.CosNaming.NamingContextPackage.*;

      public class Server extends _LoggerImplBase
      {
          public void process_event (org.omg.CORBA.Any ev)
          {
              MetricEvent event = MetricEventHelper.extract(ev);

              System.out.println("Processing event chars: ");

              for (int i = 0; i < event.metric.length(); i++) {
                  System.out.println("" + i + ": "
                                     + Character.UnicodeBlock.of(event.metric.charAt(i)));
              }

              System.out.println("testa: ");
              System.out.println(""
                                 + Character.UnicodeBlock.of(event.testa));

              System.out.println("testb: ");
              System.out.println(""
                                 + Character.UnicodeBlock.of(event.testb));

          }
          
          public static void main(String args[])
          {
      try{
      ORB orb = ORB.init(args, System.getProperties());

      // create servant and register it with the ORB
      Server loggerRef = new Server();
      orb.connect(loggerRef);

      // get the root naming context
      org.omg.CORBA.Object objRef =
      orb.resolve_initial_references("NameService");
      NamingContext ncRef = NamingContextHelper.narrow(objRef);

      // bind the Object Reference in Naming
      NameComponent nc = new NameComponent("testref", "");
      NameComponent path[] = {nc};
      ncRef.rebind(path, loggerRef);

                  System.out.println("Server is ready");
                  orb.run();

      } catch (Exception e) {
      e.printStackTrace();
      }
          }
      }
              
              

            eandersosunw Everett Anderson (Inactive)
            eandersosunw Everett Anderson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: