javax.annotation.meta.TypeQualifierValidator Java Examples

The following examples show how to use javax.annotation.meta.TypeQualifierValidator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ValidationSecurityManager.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
private boolean inValidation() {
    for (Class<?> c : getClassContext()) {
        if (TypeQualifierValidator.class.isAssignableFrom(c)
                || c.getClassLoader() == VALIDATOR_LOADER) {
            return true;
        }
    }
    return false;
}
 
Example #2
Source File: ValidationSecurityManager.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static <A extends Annotation> When sandboxedValidation(A proxy, TypeQualifierValidator<A> v, @CheckForNull Object constantValue) {
    if (performingValidation.get()) {
        throw new IllegalStateException("recursive validation");
    }

    try {
        performingValidation.set(Boolean.TRUE);
        if (TypeQualifierValue.DEBUG_CLASSLOADING) {
            System.out.println("Performing validation in thread " + Thread.currentThread().getName());
        }
        try {
            When result = v.forConstantValue(proxy, constantValue);
            if (!performingValidation.get()) {
                throw new IllegalStateException("performingValidation not set when validation completes");
            }
            return result;
        } catch (ClassCastException e) {
            Class<? extends Annotation> c = proxy.getClass();
            System.out.println(c.getName() + " extends " + c.getSuperclass().getName());
            for (Class<?> i : c.getInterfaces()) {
                System.out.println("  " + i.getName());
            }
            throw e;
        }

    } finally {
        performingValidation.set(Boolean.FALSE);
        if (TypeQualifierValue.DEBUG_CLASSLOADING) {
            System.out.println("Validation finished in thread " + Thread.currentThread().getName());
        }

    }
}
 
Example #3
Source File: TypeQualifierValue.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
private static <A extends Annotation> TypeQualifierValidator<A> getValidator(
        Class<? extends TypeQualifierValidator<A>> checkerClass)
        throws InstantiationException, IllegalAccessException {
    return checkerClass.newInstance();
}
 
Example #4
Source File: ValidationSecurityManagerTest.java    From spotbugs with GNU Lesser General Public License v2.1 2 votes vote down vote up
public When test(TypeQualifierValidator<SlashedClassName> validator) {
    return ValidationSecurityManager.sandboxedValidation(ANNOTATION, validator, "java/lang/String");

}