throw new IllegalArgumentException(msg);
throw new ApiUsageException(msg);
    public static void errorOnViolation(Class implClass, Method mthd, Object[] args)     throws ValidationException    {        /* find concrete method */        Method implMethod;        try        {            implMethod = implClass.getMethod(mthd.getName(), (Class[]) mthd                    .getParameterTypes());        } catch (SecurityException e)        {            throw new InternalException(                    "Not allowed to perform reflection for testing API.\n" +                    String.format("Class:%s Method:%s",implClass.getName(),mthd));        } catch (NoSuchMethodException e)        {            return; // TODO No method == no violation.         }        log.info("Checking: " + implMethod);        /* get arrays of arguments with parameters */        if ( args == null )            args = new Object[]{};                Annotation[][] anns = implMethod.getParameterAnnotations();        for (int i = 0; i < args.length; i++)        {            Object arg = args[i];            Annotation[] annotations = anns[i];            boolean validated = false;            for (Annotation annotation : annotations)            {                if (NotNull.class.equals(annotation.annotationType()))                {                    if (null == arg)                    {                        String msg = "Argument " + i + " to " + implMethod                                + " may not be null.";                        log.warn(msg);                        throw new IllegalArgumentException(msg);                    }                }                else if (Validate.class.equals(annotation.annotationType()))                {                    validated = true;                    Validate validator = (Validate) annotation;                    Class[] validClasses = validator.value();                    ValidSet validSet = new ValidSet( validClasses );                    String msg = "Argument " + i + " must be of a type in:"                            + validSet;                    if (null == arg) {                        // handled by NotNull                    }                                        else if (arg instanceof Collection)                    {                        Collection coll = (Collection) arg;                        for (Object object : coll)                        {                            if ( ! validSet.isValid( object.getClass() ))                                throw new IllegalArgumentException(msg);                        }                    }                    else                    {                        if ( ! validSet.isValid( arg.getClass() ))                        {                            throw new IllegalArgumentException(msg);                        }                    }                }            }            /* warn if someone's forgotten to annotate a method */            if (arg instanceof Collection && !validated)                throw new ValidationException(implMethod                        + " is missing a required @" + Validate.class.getName()                        + " annotation. Refusing to proceed...");        }    }