aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2011-06-20 20:59:40 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2011-06-20 21:05:06 +0200
commitbdcbd1bac40ddbfeda22a99285976e2a92fd59df (patch)
tree811c497a8a0ec309986d325410ca2a9e7f9a6419 /src
parent1c883cb13f1c1595c0aaefe1b3ff1fb9c734ed5b (diff)
downloadlombok-bdcbd1bac40ddbfeda22a99285976e2a92fd59df.tar.gz
lombok-bdcbd1bac40ddbfeda22a99285976e2a92fd59df.tar.bz2
lombok-bdcbd1bac40ddbfeda22a99285976e2a92fd59df.zip
SpiLoadUtil's findAnnotationClass didn't work with extends Foo<T>, only with implements Foo<T>. Fixed this.
Diffstat (limited to 'src')
-rw-r--r--src/core/lombok/core/SpiLoadUtil.java39
1 files changed, 25 insertions, 14 deletions
diff --git a/src/core/lombok/core/SpiLoadUtil.java b/src/core/lombok/core/SpiLoadUtil.java
index 143cba13..09a59709 100644
--- a/src/core/lombok/core/SpiLoadUtil.java
+++ b/src/core/lombok/core/SpiLoadUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2009 Reinier Zwitserloot and Roel Spilker.
+ * Copyright © 2009-2011 Reinier Zwitserloot and Roel Spilker.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -151,22 +151,16 @@ public class SpiLoadUtil {
* It returns an annotation type because it is used exclusively to figure out which annotations are
* being handled by {@link lombok.eclipse.EclipseAnnotationHandler} and {@link lombok.javac.JavacAnnotationHandler}.
*/
- @SuppressWarnings("unchecked")
public static Class<? extends Annotation> findAnnotationClass(Class<?> c, Class<?> base) {
if (c == Object.class || c == null) return null;
+ Class<? extends Annotation> answer = null;
+
+ answer = findAnnotationHelper(base, c.getGenericSuperclass());
+ if (answer != null) return answer;
+
for (Type iface : c.getGenericInterfaces()) {
- if (iface instanceof ParameterizedType) {
- ParameterizedType p = (ParameterizedType)iface;
- if (!base.equals(p.getRawType())) continue;
- Type target = p.getActualTypeArguments()[0];
- if (target instanceof Class<?>) {
- if (Annotation.class.isAssignableFrom((Class<?>) target)) {
- return (Class<? extends Annotation>) target;
- }
- }
-
- throw new ClassCastException("Not an annotation type: " + target);
- }
+ answer = findAnnotationHelper(base, iface);
+ if (answer != null) return answer;
}
Class<? extends Annotation> potential = findAnnotationClass(c.getSuperclass(), base);
@@ -178,4 +172,21 @@ public class SpiLoadUtil {
return null;
}
+
+ @SuppressWarnings("unchecked")
+ private static Class<? extends Annotation> findAnnotationHelper(Class<?> base, Type iface) {
+ if (iface instanceof ParameterizedType) {
+ ParameterizedType p = (ParameterizedType)iface;
+ if (!base.equals(p.getRawType())) return null;
+ Type target = p.getActualTypeArguments()[0];
+ if (target instanceof Class<?>) {
+ if (Annotation.class.isAssignableFrom((Class<?>) target)) {
+ return (Class<? extends Annotation>) target;
+ }
+ }
+
+ throw new ClassCastException("Not an annotation type: " + target);
+ }
+ return null;
+ }
}