Wed, 07 Aug 2013 10:41:20 +0100
8020997: TreeMaker.AnnotationBuilder creates broken element literals with repeating annotations
Reviewed-by: jjg, jfranck
1.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java Tue Aug 06 17:12:42 2013 -0700 1.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java Wed Aug 07 10:41:20 2013 +0100 1.3 @@ -781,7 +781,7 @@ 1.4 class AnnotationBuilder implements Attribute.Visitor { 1.5 JCExpression result = null; 1.6 public void visitConstant(Attribute.Constant v) { 1.7 - result = Literal(v.value); 1.8 + result = Literal(v.type.getTag(), v.value); 1.9 } 1.10 public void visitClass(Attribute.Class clazz) { 1.11 result = ClassLiteral(clazz.classType).setType(syms.classType);
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/tools/javac/T8020997/CannotCompileRepeatedAnnoTest.java Wed Aug 07 10:41:20 2013 +0100 2.3 @@ -0,0 +1,46 @@ 2.4 + 2.5 +/* 2.6 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 2.7 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 + * 2.9 + * This code is free software; you can redistribute it and/or modify it 2.10 + * under the terms of the GNU General Public License version 2 only, as 2.11 + * published by the Free Software Foundation. 2.12 + * 2.13 + * This code is distributed in the hope that it will be useful, but WITHOUT 2.14 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.15 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.16 + * version 2 for more details (a copy is included in the LICENSE file that 2.17 + * accompanied this code). 2.18 + * 2.19 + * You should have received a copy of the GNU General Public License version 2.20 + * 2 along with this work; if not, write to the Free Software Foundation, 2.21 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.22 + * 2.23 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2.24 + * or visit www.oracle.com if you need additional information or have any 2.25 + * questions. 2.26 + */ 2.27 + 2.28 +/* 2.29 + * @test 2.30 + * @bug 8020997 2.31 + * @summary Cannot compile class with repeating annotation 2.32 + * @compile CannotCompileRepeatedAnnoTest.java 2.33 + */ 2.34 + 2.35 +import java.lang.annotation.*; 2.36 + 2.37 +@Anno(req = true) 2.38 +@Anno() 2.39 +public class CannotCompileRepeatedAnnoTest { 2.40 +} 2.41 + 2.42 +@Repeatable(Container.class) 2.43 +@interface Anno { 2.44 + boolean req() default false; 2.45 +} 2.46 + 2.47 +@interface Container{ 2.48 + Anno[] value(); 2.49 +}