code: public static <T> Class<T> toClass(CtClass ctClass, ClassLoader loader, ProtectionDomain domain) throws CannotCompileException {
          try {
              byte[] byteCode = ctClass.toBytecode();
  
              if (domain == null) {
                  return bruteForceDefineClass(DEFINE_METHOD_NO_DOMAIN, loader, ctClass.getName(), byteCode, 0, byteCode.length);
              } else {
                  return bruteForceDefineClass(DEFINE_METHOD_WITH_DOMAIN, loader, ctClass.getName(), byteCode, 0, byteCode.length, domain);
              }
          } catch (Exception e) {
              ExceptionUtil.propagateIfInstanceOf(e, CannotCompileException.class);
              ExceptionUtil.propagateIfPossible(e);
  
              throw new CannotCompileException(e);
          } finally {
              ctClass.prune();
          }
      }
docs: Installs the given {@code CtClass} into the given class-loader and returns
  it as a new class.
  
  @param ctClass class to load
  @param loader class-loader to install into
  @param domain protection domain, may be null
  @param <T> class type
  @return new class
  @throws CannotCompileException if the class cannot be compiled