--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Tue Feb 12 19:25:09 2013 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Tue Feb 12 17:15:29 2013 -0800
@@ -2068,7 +2068,15 @@
@Override
public Type visitAnnotatedType(AnnotatedType t, Boolean recurse) {
- return new AnnotatedType(t.typeAnnotations, erasure(t.underlyingType, recurse));
+ Type erased = erasure(t.underlyingType, recurse);
+ if (erased.getKind() == TypeKind.ANNOTATED) {
+ // This can only happen when the underlying type is a
+ // type variable and the upper bound of it is annotated.
+ // The annotation on the type variable overrides the one
+ // on the bound.
+ erased = ((AnnotatedType)erased).underlyingType;
+ }
+ return new AnnotatedType(t.typeAnnotations, erased);
}
};