/**
  * Makes a dynamic stub class, if it does not already exist.
  *
  * @param myClass The class to create a stub for
  * @return The dynamic stub class
  */
 public static Class<?> makeStubClass(final Class<?> myClass) {
   final String stubClassName = myClass + "_Stub";
   ClassLoader cl = SecurityActions.getContextClassLoader();
   if (cl == null) {
     cl = myClass.getClassLoader();
   }
   if (cl == null) {
     throw EjbMessages.MESSAGES.couldNotFindClassLoaderForStub(stubClassName);
   }
   Class<?> theClass;
   try {
     theClass = cl.loadClass(stubClassName);
   } catch (ClassNotFoundException e) {
     try {
       final ClassFile clazz = IIOPStubCompiler.compile(myClass, stubClassName);
       theClass = clazz.define(cl);
     } catch (RuntimeException ex) {
       // there is a possibility that another thread may have defined the same class in the
       // meantime
       try {
         theClass = cl.loadClass(stubClassName);
       } catch (ClassNotFoundException e1) {
         EjbLogger.EJB3_LOGGER.dynamicStubCreationFailed(stubClassName, ex);
         throw ex;
       }
     }
   }
   return theClass;
 }