private static <T> T getGroovyScriptExecutionResultOrThrow(final Class<T> clazz, final Object result) {
        if (result != null && !clazz.isAssignableFrom(result.getClass())) {
            throw new ClassCastException("Result [" + result + " is of type " + result.getClass() + " when we were expecting " + clazz);
        }
        return (T) result;
    }
New groovy class loader.

@return the groovy class loader
core/cas-server-core-scripting/src/main/java/org/apereo/cas/util/scripting/ScriptingUtils.java