langtools/test/tools/javac/annotations/typeAnnotations/TestAnonInnerInstance1.java
author emc
Wed, 16 Oct 2013 16:33:04 -0400
changeset 21043 3b000be15694
permissions -rw-r--r--
8026286: Improper locking of annotation queues causes assertion failures. 8026063: Calls to annotate.flush() cause incorrect type annotations to be generated. Summary: Fix locking in ClassReader.java Reviewed-by: jfranck
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21043
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
     1
/*
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
     4
 *
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
     7
 * published by the Free Software Foundation.
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
     8
 *
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    13
 * accompanied this code).
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    14
 *
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    18
 *
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    21
 * questions.
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    22
 */
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    23
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    24
/*
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    25
 * @test
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    26
 * @bug 8026286
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    27
 * @summary This test previously forced an assertion to fail, due to
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    28
 *          TypeAnnotationPosition visiting a tree node prior to
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    29
 *          memberEnter.
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    30
 * @compile TestAnonInnerInstance1.java
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    31
 */
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    32
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    33
import java.lang.annotation.*;
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    34
import static java.lang.annotation.RetentionPolicy.*;
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    35
import static java.lang.annotation.ElementType.*;
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    36
import java.util.List;
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    37
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    38
class TestAnonInnerInstance1<T> {
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    39
    Object mtest(TestAnonInnerInstance1<T> t){ return null; }
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    40
    Object mmtest(TestAnonInnerInstance1<T> t){ return null; }
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    41
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    42
    public void test() {
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    43
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    44
        mtest(new TestAnonInnerInstance1<T>() {
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    45
                  class InnerAnon<U> { // Test1$1$InnerAnon.class
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    46
                      @A @B @C @D String ia_m1(){ return null; };
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    47
                  }
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    48
    //If this is commented out, annotations are attributed correctly
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    49
                  InnerAnon<String> IA = new InnerAnon< String>();
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    50
              });
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    51
   }
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    52
}
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    53
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    54
@Retention(RUNTIME) @Target({TYPE_USE,FIELD}) @interface A { }
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    55
@Retention(RUNTIME) @Target({TYPE_USE,METHOD}) @interface B { }
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    56
@Retention(CLASS) @Target({TYPE_USE,FIELD}) @interface C { }
3b000be15694 8026286: Improper locking of annotation queues causes assertion failures.
emc
parents:
diff changeset
    57
@Retention(CLASS) @Target({TYPE_USE,METHOD}) @interface D { }