rex.initCause(ex);
rex.detail = ex;
  public RemoteException mapSystemException(SystemException ex)  {    RemoteException rex;    String status;    switch (ex.completed.value())  {        case CompletionStatus._COMPLETED_MAYBE:          status = "Maybe";          break;        case CompletionStatus._COMPLETED_NO:          status = "No";          break;        case CompletionStatus._COMPLETED_YES:          status = "Yes";          break;        default:          status = "Unexpected completion status " + ex.completed.value();  }    String name = ex.getClass().getName();    if (name.startsWith(m_StandardPackage))      name = name.substring(m_StandardPackage.length());    String message = "CORBA " + name + " 0x" + Integer.toHexString(ex.minor)      + " " + status;    if (ex instanceof COMM_FAILURE)      rex = new MarshalException(message, ex);    else if (ex instanceof INV_OBJREF)  {        rex = new NoSuchObjectException(message);        rex.initCause(ex);  }    else if (ex instanceof NO_PERMISSION)      rex = new AccessException(message, ex);    else if (ex instanceof MARSHAL)      rex = new MarshalException(message, ex);    else if (ex instanceof BAD_PARAM)      rex = new MarshalException(message, ex);    else if (ex instanceof OBJECT_NOT_EXIST)      {        rex = new NoSuchObjectException(message);        rex.initCause(ex);      }    else if (ex instanceof TRANSACTION_REQUIRED)      {        rex = new TransactionRequiredException(message);        rex.initCause(ex);      }    else if (ex instanceof TRANSACTION_ROLLEDBACK)  {        rex = new TransactionRolledbackException(message);        rex.initCause(ex);  }    else if (ex instanceof INVALID_TRANSACTION)      {        rex = new InvalidTransactionException(message);        rex.initCause(ex);      }    else if (ex instanceof UNKNOWN)      rex = wrapException(ex.getCause());    else      rex = new RemoteException(message, ex);        return rex;  }