docs: public Throwable setException(Throwable ex)
      {
          // Validate the state
          if (ivMethod == null)
          {
              throw new IllegalStateException("WSEJBEndpointManager.ejbPreInvoke must be called first.");
          }
          if (ivMethodContext == null)
          {
              if (ivMethodIndex != Integer.MIN_VALUE)
              {
                  throw new IllegalStateException("WSEJBEndpointManager.ejbPostInvoke already called.");
              }
              // ejbPreInvoke called but failed; allow setException
              return ex;
          }
  
          if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
              Tr.entry(tc, "setException : " + ex.getClass().getName());
  
          Throwable mappedException = null;
          ExceptionMappingStrategy exStrategy = ivMethodContext.getExceptionMappingStrategy();
  
          // -----------------------------------------------------------------------
          // First, determine if this is a 'checked' application exception.
          //
          // Where 'checked' means it is on the throws clause, and application
          // (per EJB spec) means it must be a subclass of Exception (including
          // RuntimeException), but not a subclass of RemoteException.
          //
          // Checked application exceptions are not mapped, so just set it on
          // the method context (EJSDeployedSupport) and return the same exception.
          // -----------------------------------------------------------------------
  
          if (ex instanceof Exception &&
              !(ex instanceof RemoteException))
          {
              Class<?> exceptionClass = ex.getClass();
              Class<?>[] checkedExceptions = ivMethod.getExceptionTypes();
  
              // interate checked exception array and look for a match.
              for (Class<?> checkedClass : checkedExceptions)
              {
                  if (checkedClass.isAssignableFrom(exceptionClass))
                  {
                      // This is a checked exception, so call setCheckedException
                      // to record this fact, and return the exception - no mapping.
                      exStrategy.setCheckedException(ivMethodContext, (Exception) ex);
                      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                          Tr.exit(tc, "setException : " + ex.getClass().getName());
                      return ex;
                  }
              }
          }
  
          // -----------------------------------------------------------------------
          // This is an 'unchecked' exception - perform mapping as necessary.
          //
          // Note that this may still be an application exception, as beginning
          // with EJB 3.0, RuntimeExceptions may also be application exceptions.
          //
          // Set the exception on the method context (EJSDeployedSupport), which
          // will determine if this is an application exception or not, perform
          // any necessary mapping, and allow postInvoke to properly decide
          // whether to rollback the transaction or not.
          // -----------------------------------------------------------------------
  
          mappedException = exStrategy.setUncheckedException(ivMethodContext, ex);
  
          if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
              Tr.exit(tc, "setException : " + mappedException.getClass().getName());
  
          return mappedException;
      }