OverloadMethods - Method Signatures overloaded in Java

Description:

In Java it is possible to overload method signatures. Because OMG's IDL does not allow method overloading, the OMG Java-to-IDL mapping defines a simple name mangling scheme for overloaded methods.

If a method is uniquely defined in a base interface its name will not be mangled within the scope of that interface, but if the method is overloaded by a derived method the name is enhanced within the scope of the derived interface by adding the parameter type names to the original method name, i.e.

            void hello(int x) --> void hello__long(in long x)
          

The following example shows how overloaded methods are mapped to .NET.

Source:

\DemoJava\OverloadMethods

Mapping:

overloaded Java method <---> unique .NET method

Example

Step 1. Write the Java server:

  public interface Greetings extends Remote
  {
    String hello( String Name) throws RemoteException;
    String hello( String FirstName, String LastName) throws RemoteException;  
  }

Step 2. Write the .NET client:

Call the Server:

  ...
  System.Console.WriteLine("{0}", oGreetings.hello__CORBA_WStringValue( "Joe"));
  System.Console.WriteLine("{0}", oGreetings.hello__CORBA_WStringValue__CORBA_WStringValue("Joe", "Foo"));  
  ...

Step 3. Run the example

a.) Start the sun name service on port 10050:

    > start orbd -ORBInitialPort 10050  

(could also use startNameService.bat located in the DemoJava directory to quick start the name service)

b.) Start the java server by using JNDI CosNaming and work with a name service running on 'localhost' at port '10050':

    > start java -cp .;Server.jar -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory -Djava.naming.provider.url=iiop://localhost:10050 Server  

(could also use buildServer.bat and startServer.bat located in the JavaServer directory to quick build and run the Java Server)

c.) Start the .NET Client.