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