How do I get the real annotation instead of a proxy from ConstraintDescriptor::getAnnotation? (javax.validation Apache Bval)
问题 I'm trying to get a Class object reference for the annotation which caused a ConstraintViolation in the javax.validation package (Apache Bval implementation). After getting some ConstraintViolations, I pass them into the following function: private Class<?> getConstraintAnnotation(final ConstraintViolation<?> constraintViolation) { return constraintViolation .getConstraintDescriptor() .getAnnotation() .getClass(); } And this returns a class object whose getName() , getCanonicalName() , and