OpenJDK / type-annotations / type-annotations / langtools
changeset 2421:3e6b55fce59a
Fix for 8011722: in throws clauses the left-most type-annotations need to be inserted into the most-inner type. Expand bytecode test cases to ensure the correct information is stored.
author | wmdietl |
---|---|
date | Sun, 14 Apr 2013 17:15:27 -0700 |
parents | 4173877bdac9 |
children | a90456029dea |
files | src/share/classes/com/sun/tools/javac/parser/JavacParser.java test/tools/javac/annotations/typeAnnotations/referenceinfos/MethodThrows.java |
diffstat | 2 files changed, 34 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Sun Apr 14 17:13:53 2013 -0700 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Sun Apr 14 17:15:27 2013 -0700 @@ -3551,18 +3551,24 @@ ListBuffer<JCExpression> ts = new ListBuffer<JCExpression>(); List<JCAnnotation> typeAnnos = typeAnnotationsOpt(); - if (!typeAnnos.isEmpty()) - ts.append(toP(F.at(typeAnnos.head.pos).AnnotatedType(typeAnnos, qualident(true)))); - else - ts.append(qualident(true)); + JCExpression qi = qualident(true); + if (!typeAnnos.isEmpty()) { + JCExpression at = insertAnnotationsToMostInner(qi, typeAnnos, false); + ts.append(at); + } else { + ts.append(qi); + } while (token.kind == COMMA) { nextToken(); typeAnnos = typeAnnotationsOpt(); - if (!typeAnnos.isEmpty()) - ts.append(toP(F.at(typeAnnos.head.pos).AnnotatedType(typeAnnos, qualident(true)))); - else - ts.append(qualident(true)); + qi = qualident(true); + if (!typeAnnos.isEmpty()) { + JCExpression at = insertAnnotationsToMostInner(qi, typeAnnos, false); + ts.append(at); + } else { + ts.append(qi); + } } return ts.toList(); }
--- a/test/tools/javac/annotations/typeAnnotations/referenceinfos/MethodThrows.java Sun Apr 14 17:13:53 2013 -0700 +++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/MethodThrows.java Sun Apr 14 17:15:27 2013 -0700 @@ -54,4 +54,24 @@ public String interfaceMethod() { return "interface Test { void test() throws @TA RuntimeException, IllegalArgumentException, @TB Exception; }"; } + + @TADescriptions({ + @TADescription(annotation = "TA", type = THROWS, typeIndex = 0, + genericLocation = {}), + @TADescription(annotation = "TB", type = THROWS, typeIndex = 0, + genericLocation = {1, 0}), + @TADescription(annotation = "TC", type = THROWS, typeIndex = 0, + genericLocation = {1, 0, 1, 0}), + @TADescription(annotation = "TD", type = THROWS, typeIndex = 1, + genericLocation = {}), + @TADescription(annotation = "TE", type = THROWS, typeIndex = 1, + genericLocation = {1, 0}), + @TADescription(annotation = "TF", type = THROWS, typeIndex = 1, + genericLocation = {1, 0, 1, 0}) + }) + public String NestedTypes() { + return "class Outer { class Middle { class Inner1 extends Exception {}" + + " class Inner2 extends Exception{} } }" + + "class Test { void test() throws @TA Outer.@TB Middle.@TC Inner1, @TD Outer.@TE Middle.@TF Inner2 { } }"; + } }