public static org.omg.CORBA.Object remoteToCorba(Remote remoteObj,ORB orb) throws ClassNotFoundException, ConfigurationException {
synchronized (CorbaUtils.class) {
    if (toStubMethod == null) {
      initMethodHandles();
    }
  }
  java.lang.Object stub;
  try {
    stub=toStubMethod.invoke(null,new java.lang.Object[]{remoteObj});
  }
 catch (  InvocationTargetException e) {
    Throwable realException=e.getTargetException();
    ConfigurationException ce=new ConfigurationException("Problem with PortableRemoteObject.toStub(); object not exported or stub not found");
    ce.setRootCause(realException);
    throw ce;
  }
catch (  IllegalAccessException e) {
    ConfigurationException ce=new ConfigurationException("Cannot invoke javax.rmi.PortableRemoteObject.toStub(java.rmi.Remote)");
    ce.setRootCause(e);
    throw ce;
  }
  if (!corbaStubClass.isInstance(stub)) {
    return null;
  }
  try {
    connectMethod.invoke(stub,new java.lang.Object[]{orb});
  }
 catch (  InvocationTargetException e) {
    Throwable realException=e.getTargetException();
    if (!(realException instanceof java.rmi.RemoteException)) {
      ConfigurationException ce=new ConfigurationException("Problem invoking javax.rmi.CORBA.Stub.connect()");
      ce.setRootCause(realException);
      throw ce;
    }
  }
catch (  IllegalAccessException e) {
    ConfigurationException ce=new ConfigurationException("Cannot invoke javax.rmi.CORBA.Stub.connect()");
    ce.setRootCause(e);
    throw ce;
  }
  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 ( ) ; } } java . lang . Object stub ; try { stub = toStubMethod . invoke ( null , new java . lang . Object [ ] { remoteObj } ) ; } catch ( InvocationTargetException e ) { Throwable realException = e . getTargetException ( ) ; ConfigurationException ce = new ConfigurationException ( "Problem with PortableRemoteObject.toStub(); object not exported or stub not found" ) ; ce . setRootCause ( realException ) ; throw ce ; } catch ( IllegalAccessException e ) { ConfigurationException ce = new ConfigurationException ( "Cannot invoke javax.rmi.PortableRemoteObject.toStub(java.rmi.Remote)" ) ; ce . setRootCause ( e ) ; throw ce ; } if ( ! corbaStubClass . isInstance ( stub ) ) { return null ; } try { connectMethod . invoke ( stub , new java . lang . Object [ ] { orb } ) ; } catch ( InvocationTargetException e ) { Throwable realException = e . getTargetException ( ) ; if ( ! ( realException instanceof java . rmi . RemoteException ) ) { ConfigurationException ce = new ConfigurationException ( "Problem invoking javax.rmi.CORBA.Stub.connect()" ) ; ce . setRootCause ( realException ) ; throw ce ; } } catch ( IllegalAccessException e ) { ConfigurationException ce = new ConfigurationException ( "Cannot invoke javax.rmi.CORBA.Stub.connect()" ) ; ce . setRootCause ( e ) ; throw ce ; } 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 ;
