code: public static <T extends Closure<?>> T instantiateClosure(Class<T> closureType, Object owner, Object thisObject) {
      try {
        Constructor<T> constructor = closureType.getConstructor(Object.class, Object.class);
        return constructor.newInstance(owner, thisObject);
      } catch (Exception e) {
        ExceptionUtil.sneakyThrow(e.getCause());
        return null; // never reached
      }
    }
docs: Note: This method may throw checked exceptions although it doesn't say so.