iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/naming/jndi/CorbaUtils.java
public static org.omg.CORBA.Object remoteToCorba(Remote remoteObj, ORB orb)
            throws ClassNotFoundException, ConfigurationException {
        synchronized (CorbaUtils.class) {
            if (toStubMethod == null) {
                initMethodHandles();
            }
        }

// First, get remoteObj's stub

        // javax.rmi.CORBA.Stub stub = PortableRemoteObject.toStub(remoteObj);

        java.lang.Object stub;

        try {
            stub = toStubMethod.invoke(null, new java.lang.Object[]{remoteObj});

        } catch (InvocationTargetException e) {
            Throwable realException = e.getTargetException();
            // realException.printStackTrace();
            ConfigurationException ce = IIOPLogger.ROOT_LOGGER.problemInvokingPortableRemoteObjectToStub();
            ce.setRootCause(realException);
            throw ce;
        } catch (IllegalAccessException e) {
            ConfigurationException ce = IIOPLogger.ROOT_LOGGER.cannotInvokePortableRemoteObjectToStub();
            ce.setRootCause(e);
            throw ce;
        }

// Next, make sure that the stub is javax.rmi.CORBA.Stub

        if (!corbaStubClass.isInstance(stub)) {
            return null;  // JRMP implementation or JRMP stub
        }

// Next, make sure that the stub is connected
        // Invoke stub.connect(orb)
        try {
            connectMethod.invoke(stub, new java.lang.Object[]{orb});

        } catch (InvocationTargetException e) {
            Throwable realException = e.getTargetException();
            // realException.printStackTrace();

            if (!(realException instanceof java.rmi.RemoteException)) {
                ConfigurationException ce = IIOPLogger.ROOT_LOGGER.problemInvokingStubConnect();
                ce.setRootCause(realException);
                throw ce;
            }
            // ignore RemoteException because stub might have already
            // been connected
        } catch (IllegalAccessException e) {
            ConfigurationException ce = IIOPLogger.ROOT_LOGGER.cannotInvokeStubConnect();
            ce.setRootCause(e);
            throw ce;
        }
// Finally, return stub
        return (org.omg.CORBA.Object) stub;
    }
public static org.omg.CORBA.Object remoteToCorba(Remote remoteObj, ORB orb)
            throws ClassNotFoundException, ConfigurationException {
        synchronized (CorbaUtils.class) {
            if (toStubMethod == null) {
                initMethodHandles();
            }
        }

// First, get remoteObj's stub

        // javax.rmi.CORBA.Stub stub = PortableRemoteObject.toStub(remoteObj);

        java.lang.Object stub;

        try {
            stub = toStubMethod.invoke(null, new java.lang.Object[]{remoteObj});

        } catch (InvocationTargetException e) {
            Throwable realException = e.getTargetException();
            // realException.printStackTrace();
            ConfigurationException ce = IIOPLogger.ROOT_LOGGER.problemInvokingPortableRemoteObjectToStub();
            ce.setRootCause(realException);
            throw ce;
        } catch (IllegalAccessException e) {
            ConfigurationException ce = IIOPLogger.ROOT_LOGGER.cannotInvokePortableRemoteObjectToStub();
            ce.setRootCause(e);
            throw ce;
        }

// Next, make sure that the stub is javax.rmi.CORBA.Stub

        if (!corbaStubClass.isInstance(stub)) {
            return null;  // JRMP implementation or JRMP stub
        }

// Next, make sure that the stub is connected
        // Invoke stub.connect(orb)
        try {
            connectMethod.invoke(stub, new java.lang.Object[]{orb});

        } catch (InvocationTargetException e) {
            Throwable realException = e.getTargetException();
            // realException.printStackTrace();

            if (!(realException instanceof java.rmi.RemoteException)) {
                ConfigurationException ce = IIOPLogger.ROOT_LOGGER.problemInvokingStubConnect();
                ce.setRootCause(realException);
                throw ce;
            }
            // ignore RemoteException because stub might have already
            // been connected
        } catch (IllegalAccessException e) {
            ConfigurationException ce = IIOPLogger.ROOT_LOGGER.cannotInvokeStubConnect();
            ce.setRootCause(e);
            throw ce;
        }
// Finally, return stub
        return (org.omg.CORBA.Object) stub;
    }
public static org . omg . CORBA . Object remoteToCorba ( Remote remoteObj , ORB orb ) throws ClassNotFoundException , ConfigurationException { synchronized ( CorbaUtils . class ) { if ( toStubMethod == null ) { initMethodHandles ( ) ; } } // First, get remoteObj's stub // javax.rmi.CORBA.Stub stub = PortableRemoteObject.toStub(remoteObj); java . lang . Object stub ; try { stub = toStubMethod . invoke ( null , new java . lang . Object [ ] { remoteObj } ) ; } catch ( InvocationTargetException e ) { Throwable realException = e . getTargetException ( ) ; // realException.printStackTrace(); ConfigurationException ce = IIOPLogger . ROOT_LOGGER . problemInvokingPortableRemoteObjectToStub ( ) ; ce . setRootCause ( realException ) ; throw ce ; } catch ( IllegalAccessException e ) { ConfigurationException ce = IIOPLogger . ROOT_LOGGER . cannotInvokePortableRemoteObjectToStub ( ) ; ce . setRootCause ( e ) ; throw ce ; } // Next, make sure that the stub is javax.rmi.CORBA.Stub if ( ! corbaStubClass . isInstance ( stub ) ) { return null ; // JRMP implementation or JRMP stub } // Next, make sure that the stub is connected // Invoke stub.connect(orb) try { connectMethod . invoke ( stub , new java . lang . Object [ ] { orb } ) ; } catch ( InvocationTargetException e ) { Throwable realException = e . getTargetException ( ) ; // realException.printStackTrace(); if ( ! ( realException instanceof java . rmi . RemoteException ) ) { ConfigurationException ce = IIOPLogger . ROOT_LOGGER . problemInvokingStubConnect ( ) ; ce . setRootCause ( realException ) ; throw ce ; } // ignore RemoteException because stub might have already // been connected } catch ( IllegalAccessException e ) { ConfigurationException ce = IIOPLogger . ROOT_LOGGER . cannotInvokeStubConnect ( ) ; ce . setRootCause ( e ) ; throw ce ; } // Finally, return stub return ( org . omg . CORBA . Object ) stub ; }
Returns the CORBA object reference associated with a Remote
object by using the javax.rmi.CORBA package.
<p/>
Use reflection to avoid hard dependencies on javax.rmi.CORBA package.
This method effective does the following:
<blockquote><pre>
java.lang.Object stub;
try {
stub = PortableRemoteObject.toStub(remoteObj);
} catch (Exception e) {
throw new ConfigurationException("Object not exported or not found");
}
if (!(stub instanceof javax.rmi.CORBA.Stub)) {
return null; // JRMP impl or JRMP stub
}
try {
((javax.rmi.CORBA.Stub)stub).connect(orb);  // try to connect IIOP stub
} catch (RemoteException e) {
// ignore 'already connected' error
}
return (javax.rmi.CORBA.Stub)stub;

@param remoteObj The non-null remote object for
@param orb       The non-null ORB to connect the remote object to
@return The CORBA Object for remoteObj; null if <tt>remoteObj</tt>
is a JRMP implementation or JRMP stub.
@throws ClassNotFoundException The RMI-IIOP package is not available
@throws ConfigurationException The CORBA Object cannot be obtained
because of configuration problems.
Returns the CORBA object reference associated with a Remote object by using the javax . rmi . CORBA package . <p / > Use reflection to avoid hard dependencies on javax . rmi . CORBA package . This method effective does the following : <blockquote > <pre > java . lang . Object stub ; try { stub = PortableRemoteObject . toStub ( remoteObj ) ; } catch ( Exception e ) { throw new ConfigurationException ( Object not exported or not found ) ; } if ( ! ( stub instanceof javax . rmi . CORBA . Stub )) { return null ; // JRMP impl or JRMP stub } try { (( javax . rmi . CORBA . Stub ) stub ) . connect ( orb ) ; // try to connect IIOP stub } catch ( RemoteException e ) { // ignore already connected error } return ( javax . rmi . CORBA . Stub ) stub ;