langtools/test/tools/javac/annotations/typeAnnotations/classfile/T8008762.java
author mchung
Wed, 27 May 2015 13:25:18 -0700
changeset 30846 2b3f379840f0
parent 30730 d3ce7619db2c
permissions -rw-r--r--
8074432: Move jdeps and javap to jdk.jdeps module Reviewed-by: jjg, alanb, erikj
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: 21043
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
/*
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    25
 * @test
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    26
 * @bug 8008762
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    27
 * @summary Type annotation on inner class in anonymous class
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    28
 *          shows up as regular annotation
30846
2b3f379840f0 8074432: Move jdeps and javap to jdk.jdeps module
mchung
parents: 30730
diff changeset
    29
 * @modules jdk.jdeps/com.sun.tools.classfile
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    30
 */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    31
import java.lang.annotation.*;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    32
import static java.lang.annotation.RetentionPolicy.*;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    33
import static java.lang.annotation.ElementType.*;
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
import com.sun.tools.classfile.*;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    36
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    37
public class T8008762 extends ClassfileTestHelper{
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    38
    public static void main(String[] args) throws Exception {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    39
        new T8008762().run();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    40
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    41
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    42
    public void run() throws Exception {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    43
        expected_tinvisibles = 0;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    44
        expected_tvisibles = 4;
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
        ClassFile cf = getClassFile("T8008762$Test$1$InnerAnon.class");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    47
        test(cf);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    48
        for (Field f : cf.fields) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    49
            test(cf, f, false);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    50
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    51
        for (Method m : cf.methods) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    52
            test(cf, m, false);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    53
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    54
        countAnnotations();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    55
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    56
        if (errors > 0)
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    57
            throw new Exception(errors + " errors found");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    58
        System.out.println("PASSED");
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
    /*********************** Test class *************************/
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    62
    static class Test {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    63
        Object mtest( Test t){ return null; }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    64
        public void test() {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    65
          mtest( new Test() {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    66
                class InnerAnon { // Test1$1$InnerAnon.class
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    67
                  @A @B String ai_data = null;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    68
                  @A @B String ai_m(){ return null; };
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    69
                }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    70
               InnerAnon IA = new InnerAnon();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    71
            });
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    72
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    73
        @Retention(RUNTIME) @Target(TYPE_USE) @interface A { }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    74
        @Retention(RUNTIME) @Target(TYPE_USE) @interface B { }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    75
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    76
}