diff -r 829f01e7f732 -r a3ad6e2ede44 src/share/classes/com/sun/tools/javac/code/Symbol.java --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java Thu Jun 19 12:22:39 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java Wed Jun 18 10:44:16 2014 +0200 @@ -779,42 +779,41 @@ @Override public List getAnnotationMirrors() { - return onlyTypeVariableAnnotations(owner.getRawTypeAttributes()); - } - - private List onlyTypeVariableAnnotations( - List candidates) { - // Declaration annotations on TypeParameters are stored in type attributes + // Declaration annotations on type variables are stored in type attributes + // on the owner of the TypeVariableSymbol + List candidates = owner.getRawTypeAttributes(); + int index = owner.getTypeParameters().indexOf(this); List res = List.nil(); for (Attribute.TypeCompound a : candidates) { - if (a.position.type == TargetType.CLASS_TYPE_PARAMETER || - a.position.type == TargetType.METHOD_TYPE_PARAMETER) + if (isCurrentSymbolsAnnotation(a, index)) res = res.prepend(a); } - return res = res.reverse(); + return res.reverse(); } - - // Helper to getAnnotation[s] @Override public Attribute.Compound getAttribute(Class annoType) { - String name = annoType.getName(); // Declaration annotations on type variables are stored in type attributes // on the owner of the TypeVariableSymbol List candidates = owner.getRawTypeAttributes(); + int index = owner.getTypeParameters().indexOf(this); for (Attribute.TypeCompound anno : candidates) - if (anno.position.type == TargetType.CLASS_TYPE_PARAMETER || - anno.position.type == TargetType.METHOD_TYPE_PARAMETER) - if (name.contentEquals(anno.type.tsym.flatName())) - return anno; + if (isCurrentSymbolsAnnotation(anno, index) && + name.contentEquals(anno.type.tsym.flatName())) + return anno; return null; } - + //where: + boolean isCurrentSymbolsAnnotation(Attribute.TypeCompound anno, int index) { + return (anno.position.type == TargetType.CLASS_TYPE_PARAMETER || + anno.position.type == TargetType.METHOD_TYPE_PARAMETER) && + anno.position.parameter_index == index; + } @Override