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 /*
25  * @test
26  * @summary Repeated type-annotations on type parm of local variable
27  *          are not written to classfile.
28  * @bug 8008769
29  * @modules jdk.jdeps/com.sun.tools.classfile
30  */
31 import java.lang.annotation.*;
32 import static java.lang.annotation.RetentionPolicy.*;
33 import static java.lang.annotation.ElementType.*;
34 import com.sun.tools.classfile.*;
35 
36 public class T8008769 extends ClassfileTestHelper{
main(String[] args)37     public static void main(String[] args) throws Exception {
38         new T8008769().run();
39     }
40 
run()41     public void run() throws Exception {
42         expected_tvisibles = 4;
43         ClassFile cf = getClassFile("T8008769$Test.class");
44         for (Method m : cf.methods) {
45             test(cf, m, true);
46         }
47         countAnnotations();
48 
49         if (errors > 0)
50             throw new Exception(errors + " errors found");
51         System.out.println("PASSED");
52     }
53 
54     /*********************** Test class *************************/
55     static class Test<T> {
test()56         public void test() {
57             Test<@A @B String>    t0 = new Test<>(); // 2 ok
58             Test<@B @B String>    t1 = new Test<>(); // 1 missing
59             Test<@A @A @A String> t2 = new Test<>(); // 1 missing
60        }
61     }
62     @Retention(RUNTIME) @Target(TYPE_USE) @Repeatable( AC.class ) @interface A { }
63     @Retention(RUNTIME) @Target(TYPE_USE) @Repeatable( BC.class ) @interface B { }
value()64     @Retention(RUNTIME) @Target(TYPE_USE) @interface AC { A[] value(); }
value()65     @Retention(RUNTIME) @Target(TYPE_USE) @interface BC { B[] value(); }
66 }
67