@SafeVarargs
  public static <T> T coerce(Object obj, Class<? extends T>... types) {
    if (types.length == 0) {
      throw new IllegalArgumentException("caller must provide at least one target type");
    }

    GroovyCastException lastException = null;

    for (Class<? extends T> type : types) {
      try {
        return GroovyRuntimeUtil.coerce(obj, type);
      } catch (GroovyCastException e) {
        lastException = e;
      }
    }

    throw lastException;
  }
Provides convenient access to Groovy language and runtime features.
By convention, all usages of Groovy's InvokerHelper and
ScriptBytecodeAdapter go through this class.

@author Peter Niederwieser
spock-core/src/main/java/org/spockframework/runtime/GroovyRuntimeUtil.java