Commit 47f7d00f authored by Elliott Hughes's avatar Elliott Hughes
Browse files

Return a more specific type from AnnotationFactory.createAnnotation.

Change-Id: Ic73ff86addb689c4b67298d45385a293ccc4ecef
parent 4323ab38
......@@ -89,11 +89,11 @@ public final class AnnotationFactory implements InvocationHandler, Serializable
* @param elements name-value pairs representing elements of the annotation
* @return a new annotation instance
*/
public static Annotation createAnnotation(Class<? extends Annotation> annotationType,
AnnotationMember[] elements) {
public static <A extends Annotation> A createAnnotation(Class<? extends Annotation> annotationType,
AnnotationMember[] elements) {
AnnotationFactory factory = new AnnotationFactory(annotationType, elements);
return (Annotation) Proxy.newProxyInstance(annotationType.getClassLoader(),
new Class[]{annotationType}, factory);
return (A) Proxy.newProxyInstance(annotationType.getClassLoader(),
new Class[]{annotationType}, factory);
}
private final Class<? extends Annotation> klazz;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment