test/tools/javac/annotations/typeAnnotations/classfile/T8008762.java

changeset 0
959103a6100f
child 2525
2eb010b6cb22
equal deleted inserted replaced
-1:000000000000 0:959103a6100f
1 /*
2 * Copyright (c) 2009, 2013, 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 * @bug 8008762
27 * @summary Type annotation on inner class in anonymous class
28 * shows up as regular annotation
29 */
30 import java.lang.annotation.*;
31 import static java.lang.annotation.RetentionPolicy.*;
32 import static java.lang.annotation.ElementType.*;
33
34 import com.sun.tools.classfile.*;
35
36 public class T8008762 extends ClassfileTestHelper{
37 public static void main(String[] args) throws Exception {
38 new T8008762().run();
39 }
40
41 public void run() throws Exception {
42 expected_tinvisibles = 0;
43 expected_tvisibles = 4;
44
45 ClassFile cf = getClassFile("T8008762$Test$1$InnerAnon.class");
46 test(cf);
47 for (Field f : cf.fields) {
48 test(cf, f, false);
49 }
50 for (Method m : cf.methods) {
51 test(cf, m, false);
52 }
53 countAnnotations();
54
55 if (errors > 0)
56 throw new Exception(errors + " errors found");
57 System.out.println("PASSED");
58 }
59
60 /*********************** Test class *************************/
61 static class Test {
62 Object mtest( Test t){ return null; }
63 public void test() {
64 mtest( new Test() {
65 class InnerAnon { // Test1$1$InnerAnon.class
66 @A @B String ai_data = null;
67 @A @B String ai_m(){ return null; };
68 }
69 InnerAnon IA = new InnerAnon();
70 });
71 }
72 @Retention(RUNTIME) @Target(TYPE_USE) @interface A { }
73 @Retention(RUNTIME) @Target(TYPE_USE) @interface B { }
74 }
75 }

mercurial