T8008769.java revision 2933:49d207bf704d
1/* 2 * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23/* 24 * @test 25 * @summary Repeated type-annotations on type parm of local variable 26 * are not written to classfile. 27 * @bug 8008769 28 * @modules jdk.compiler/com.sun.tools.classfile 29 */ 30import java.lang.annotation.*; 31import static java.lang.annotation.RetentionPolicy.*; 32import static java.lang.annotation.ElementType.*; 33import com.sun.tools.classfile.*; 34 35public class T8008769 extends ClassfileTestHelper{ 36 public static void main(String[] args) throws Exception { 37 new T8008769().run(); 38 } 39 40 public void run() throws Exception { 41 expected_tvisibles = 4; 42 ClassFile cf = getClassFile("T8008769$Test.class"); 43 for (Method m : cf.methods) { 44 test(cf, m, true); 45 } 46 countAnnotations(); 47 48 if (errors > 0) 49 throw new Exception(errors + " errors found"); 50 System.out.println("PASSED"); 51 } 52 53 /*********************** Test class *************************/ 54 static class Test<T> { 55 public void test() { 56 Test<@A @B String> t0 = new Test<>(); // 2 ok 57 Test<@B @B String> t1 = new Test<>(); // 1 missing 58 Test<@A @A @A String> t2 = new Test<>(); // 1 missing 59 } 60 } 61 @Retention(RUNTIME) @Target(TYPE_USE) @Repeatable( AC.class ) @interface A { } 62 @Retention(RUNTIME) @Target(TYPE_USE) @Repeatable( BC.class ) @interface B { } 63 @Retention(RUNTIME) @Target(TYPE_USE) @interface AC { A[] value(); } 64 @Retention(RUNTIME) @Target(TYPE_USE) @interface BC { B[] value(); } 65} 66