1 /*
2  * Copyright (c) 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 8026286
27  * @summary This test previously forced an assertion to fail, due to
28  *          TypeAnnotationPosition visiting a tree node prior to
29  *          memberEnter.
30  * @compile TestAnonInnerInstance1.java
31  */
32 
33 import java.lang.annotation.*;
34 import static java.lang.annotation.RetentionPolicy.*;
35 import static java.lang.annotation.ElementType.*;
36 import java.util.List;
37 
38 class TestAnonInnerInstance1<T> {
mtest(TestAnonInnerInstance1<T> t)39     Object mtest(TestAnonInnerInstance1<T> t){ return null; }
mmtest(TestAnonInnerInstance1<T> t)40     Object mmtest(TestAnonInnerInstance1<T> t){ return null; }
41 
test()42     public void test() {
43 
44         mtest(new TestAnonInnerInstance1<T>() {
45                   class InnerAnon<U> { // Test1$1$InnerAnon.class
46                       @A @B @C @D String ia_m1(){ return null; };
47                   }
48     //If this is commented out, annotations are attributed correctly
49                   InnerAnon<String> IA = new InnerAnon< String>();
50               });
51    }
52 }
53 
54 @Retention(RUNTIME) @Target({TYPE_USE,FIELD}) @interface A { }
55 @Retention(RUNTIME) @Target({TYPE_USE,METHOD}) @interface B { }
56 @Retention(CLASS) @Target({TYPE_USE,FIELD}) @interface C { }
57 @Retention(CLASS) @Target({TYPE_USE,METHOD}) @interface D { }
58