Permalink
Browse files

HV-603: Making sure annotation proxies can be created by using class …

…loader from annotation type
  • Loading branch information...
1 parent fbb5594 commit e816db0e49c195a58dc3c6b9bf0451cc30a142cd @gunnarmorling gunnarmorling committed Jul 28, 2012
@@ -25,7 +25,7 @@
import org.hibernate.validator.internal.util.ReflectionHelper;
/**
- * Creates live annotations (actually <code>AnnotationProxies</code>) from <code>AnnotationDescriptors</code>.
+ * Creates live annotations (actually {@link AnnotationProxy} instances) from {@code AnnotationDescriptor}s.
*
* @author Paolo Perrotta
* @author Davide Marchignoli
@@ -34,10 +34,12 @@
*/
public class AnnotationFactory {
- @SuppressWarnings("unchecked")
public static <T extends Annotation> T create(AnnotationDescriptor<T> descriptor) {
- ClassLoader classLoader = ReflectionHelper.getClassLoaderFromContext();
- Class<T> proxyClass = ( Class<T> ) Proxy.getProxyClass( classLoader, descriptor.type() );
+ @SuppressWarnings("unchecked")
+ Class<T> proxyClass = (Class<T>) Proxy.getProxyClass(
+ ReflectionHelper.getClassLoaderFromClass( descriptor.type() ),
+ descriptor.type()
+ );
InvocationHandler handler = new AnnotationProxy( descriptor );
try {
return getProxyInstance( proxyClass, handler );

0 comments on commit e816db0

Please sign in to comment.