langtools/test/tools/javac/annotations/typeAnnotations/classfile/TestNewCastArray.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: 17652
diff changeset
     2
 * Copyright (c) 2013, 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 8005681
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    27
 * @summary Repeated annotations on new,array,cast.
30846
2b3f379840f0 8074432: Move jdeps and javap to jdk.jdeps module
mchung
parents: 30730
diff changeset
    28
 * @modules jdk.jdeps/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 java.io.*;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    32
import java.util.List;
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
import java.lang.annotation.*;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    36
import static java.lang.annotation.RetentionPolicy.*;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    37
import static java.lang.annotation.ElementType.*;
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
public class TestNewCastArray {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    40
    int errors = 0;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    41
    List<String> failedTests = new java.util.LinkedList<>();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    42
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    43
    // 'b' tests fail with only even numbers of annotations (8005681).
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    44
    String[] testclasses = {"Test1",
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    45
        "Test2a", "Test3a", "Test4a", "Test5a",
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    46
        "Test2b", "Test3b", "Test4b", "Test5b"
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
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    49
    public static void main(String[] args) throws Exception {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    50
        new TestNewCastArray().run();
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
    void check(String testcase, int expected, int actual) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    54
        String res = testcase + ": (expected) " + expected + ", " + actual + " (actual): ";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    55
        if(expected == actual) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    56
            res = res.concat("PASS");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    57
        } else {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    58
            errors++;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    59
            res = res.concat("FAIL");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    60
            failedTests.add(res);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    61
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    62
        System.out.println(res);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    63
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    64
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    65
    void report() {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    66
        if(errors!=0) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    67
            System.err.println("Failed tests: " + errors +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    68
                                   "\nfailed test cases:\n");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    69
            for(String t: failedTests)
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    70
                System.err.println("  " + t);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    71
           throw new RuntimeException("FAIL: There were test failures.");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    72
           } else
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    73
            System.out.println("PASS");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    74
    }
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
    void test(String clazz, String ttype, ClassFile cf, Method m, Field f,
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    77
              String name, boolean codeattr) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    78
        int actual = 0;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    79
        int expected = 0, cexpected = 0;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    80
        int index = 0;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    81
        String memberName = null;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    82
        Attribute attr = null;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    83
        Code_attribute cAttr = null;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    84
        String testcase = "undefined";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    85
        try {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    86
        switch(ttype) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    87
            case "METHOD":
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    88
                index = m.attributes.getIndex(cf.constant_pool, name);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    89
                memberName = m.getName(cf.constant_pool);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    90
                if(index != -1)
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    91
                    attr = m.attributes.get(index);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    92
                break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    93
            case "MCODE":
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    94
                memberName = m.getName(cf.constant_pool);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    95
                //fetch index of and code attribute and annotations from code attribute.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    96
                index = m.attributes.getIndex(cf.constant_pool, Attribute.Code);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    97
                if(index!= -1) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    98
                    attr = m.attributes.get(index);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    99
                    assert attr instanceof Code_attribute;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   100
                    cAttr = (Code_attribute)attr;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   101
                    index = cAttr.attributes.getIndex(cf.constant_pool, name);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   102
                    if(index!= -1)
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   103
                        attr = cAttr.attributes.get(index);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   104
                }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   105
                break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   106
            case "FIELD":
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   107
                index = f.attributes.getIndex(cf.constant_pool, name);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   108
                memberName = f.getName(cf.constant_pool);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   109
                if(index != -1)
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   110
                    attr = f.attributes.get(index);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   111
                break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   112
            case "CODE":
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   113
                memberName = f.getName(cf.constant_pool);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   114
                //fetch index of and code attribute and annotations from code attribute.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   115
                index = cf.attributes.getIndex(cf.constant_pool, Attribute.Code);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   116
                if(index!= -1) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   117
                    attr = cf.attributes.get(index);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   118
                    assert attr instanceof Code_attribute;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   119
                    cAttr = (Code_attribute)attr;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   120
                    index = cAttr.attributes.getIndex(cf.constant_pool, name);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   121
                    if(index!= -1)
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   122
                        attr = cAttr.attributes.get(index);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   123
                }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   124
                break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   125
            default:
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   126
                break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   127
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   128
        } catch(ConstantPoolException cpe) { cpe.printStackTrace(); }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   129
        testcase = clazz+" "+ttype + ": " + memberName + ", " + name;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   130
        if(index != -1) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   131
            //count RuntimeTypeAnnotations
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   132
            assert attr instanceof RuntimeTypeAnnotations_attribute;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   133
            RuntimeTypeAnnotations_attribute tAttr =
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   134
                    (RuntimeTypeAnnotations_attribute)attr;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   135
                actual += tAttr.annotations.length;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   136
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   137
        if(memberName.compareTo("<init>")==0) memberName=clazz+memberName;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   138
        switch ( memberName ) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   139
            //METHOD:
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   140
            case "Test1<init>": expected=0; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   141
            case "testr22_22": expected=4; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   142
            case "testr11_11": expected=4; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   143
            case "testr12_21": expected=4; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   144
            case "testr20_02": expected=2; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   145
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   146
            case "Test2a<init>": cexpected=0; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   147
            case "test00_00_11_11": cexpected=4; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   148
            case "test21_12_21_12": cexpected=8; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   149
            case "test_new1": cexpected=2; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   150
            case "test_new2": cexpected=2; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   151
            case "test_cast1": cexpected=2; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   152
            case "test_cast2": cexpected=2; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   153
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   154
            case "Test2b<init>": cexpected=0; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   155
            case "test20_02_20_02": cexpected=4; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   156
            case "test22_22_22_22": cexpected=8; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   157
            case "test_new3": cexpected=1; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   158
            case "test_new4": cexpected=1; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   159
            case "test_new5": cexpected=2; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   160
            case "test_cast3": cexpected=1; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   161
            case "test_cast4": cexpected=2; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   162
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   163
            case "Test3a<init>": cexpected=10; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   164
            case "SA_21_12c": cexpected = 0; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   165
            case "SA_01_10c": expected = 0; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   166
            case "SA_11_11c": expected = 0; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   167
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   168
            case "Test3b<init>": cexpected=6; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   169
            case "SA_22_22c": cexpected = 0; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   170
            case "SA_20_02c": cexpected = 0; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   171
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   172
            case "Test3c<init>": cexpected=8; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   173
            case "SA_10_10": cexpected = 0; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   174
            case "SA_10_01": cexpected = 0; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   175
            case "SA_21_12": cexpected = 0; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   176
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   177
            case "Test3d<init>": cexpected=6; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   178
            case "SA_20_02": cexpected = 0; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   179
            case "SA_22_22": cexpected = 0; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   180
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   181
            case "Test4a<init>": cexpected=4; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   182
            case "nS_21": cexpected = 0; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   183
            case "nS_12": cexpected = 0; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   184
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   185
            case "Test4b<init>": cexpected=4; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   186
            case "nS20":  cexpected = 0; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   187
            case "nS02":  cexpected = 0; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   188
            case "nS22":  cexpected = 0; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   189
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   190
            case "Test5a<init>": cexpected=4; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   191
            case "ci11": expected = 0; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   192
            case "ci21": expected = 0; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   193
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   194
            case "Test5b<init>": cexpected=3; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   195
            case "ci2":  expected = 0; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   196
            case "ci22": expected = 0; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   197
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   198
            default: expected = 0; break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   199
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   200
        if(codeattr)
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   201
            check(testcase, cexpected, actual);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   202
        else
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   203
            check(testcase, expected, actual);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   204
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   205
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   206
    public void run() {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   207
        ClassFile cf = null;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   208
        InputStream in = null;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   209
        for( String clazz : testclasses) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   210
            String testclazz = "TestNewCastArray$" + clazz + ".class";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   211
            System.out.println("Testing " + testclazz);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   212
            try {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   213
                in = getClass().getResource(testclazz).openStream();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   214
                cf = ClassFile.read(in);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   215
                in.close();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   216
            } catch(Exception e) { e.printStackTrace();  }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   217
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   218
            if(clazz.startsWith("Test1")) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   219
                for (Field f: cf.fields)
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   220
                    test(clazz, "FIELD", cf, null, f, Attribute.RuntimeVisibleTypeAnnotations, false);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   221
                for (Method m: cf.methods)
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   222
                    test(clazz, "METHOD", cf, m, null, Attribute.RuntimeVisibleTypeAnnotations, false);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   223
            } else {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   224
                for (Field f: cf.fields)
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   225
                    test(clazz, "CODE", cf, null, f, Attribute.RuntimeVisibleTypeAnnotations, true);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   226
                for (Method m: cf.methods)
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   227
                    test(clazz, "MCODE", cf, m, null, Attribute.RuntimeVisibleTypeAnnotations, true);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   228
            }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   229
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   230
        report();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   231
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   232
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   233
    //////// test class //////////////////////////
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   234
    // "Test1" not in code attribute.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   235
    // on arrays on and in method return
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   236
    static class Test1 {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   237
        Test1(){}
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   238
        // OK expect 5, got 5
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   239
        String @A @A @B @B[] @A @A @B @B [] testr22_22(Test1 this, String param, String ... vararg) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   240
            String [][] sarray = new String [2][2];
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   241
            return sarray;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   242
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   243
        // OK expect 5, got 5
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   244
        String @A @B [] @A @B [] testr11_11(Test1 this, String param, String ... vararg) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   245
            String [][] sarray = new String [2][2];
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   246
            return sarray;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   247
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   248
        // OK expect 5, got 5
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   249
        String @A @B @B []@B @B @A[] testr12_21(Test1 this, String param, String ... vararg) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   250
            String [][] sarray = new String [2][2];
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   251
            return sarray;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   252
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   253
        // OK expect 3, got 3
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   254
        String @A @A [] @B @B [] testr20_02(Test1 this, String param, String ... vararg) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   255
            String [][] sarray = new String [2][2];
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   256
            return sarray;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   257
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   258
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   259
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   260
    // Inside method body (in method's code attribute)
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   261
    static class Test2a {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   262
        Test2a(){}
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   263
        Object o = new Integer(1);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   264
        // expect 4
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   265
        String[][] test00_00_11_11(Test2a this, String param, String ... vararg) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   266
            String [] [] sarray = new String @A @B[2] @A @B [2];
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   267
            return sarray;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   268
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   269
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   270
        // expect 8
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   271
        String[][] test21_12_21_12(Test2a this, String param, String ... vararg) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   272
            String @A @A @B [] @A @B @B [] sarray = new String @A @A @B[2] @A @B @B [2];
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   273
            return sarray;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   274
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   275
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   276
        void test_new1() { String nS_21 = new @A @A @B String("Hello");   }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   277
        void test_new2() { String nS_12 = new @A @B @B String("Hello");   }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   278
        void test_cast1() { String tcs11 = (@A @B String)o;      }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   279
        void test_cast2() { String tcs21 = (@A @A @B String)o;   }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   280
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   281
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   282
    static class Test2b {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   283
        Test2b(){}
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   284
        Object o = new Integer(1);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   285
        // expect 4
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   286
        String[][] test20_02_20_02(Test2b this, String param, String ... vararg) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   287
            String @A @A [] @B @B [] sarray = new String @A @A[2] @B @B [2];
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   288
            return sarray;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   289
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   290
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   291
        // expect 8
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   292
        String[][] test22_22_22_22(Test2b this, String param, String ... vararg) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   293
            String @A @A @B @B [] @A @A @B @B [] sarray = new String @A @A @B @B [2] @A @A @B @B [2];
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   294
            return sarray;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   295
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   296
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   297
        void test_new3() { String nS20 = new @A @A String("Hello");       }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   298
        void test_new4() { String nS02 = new @B @B String("Hello");       }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   299
        void test_new5() { String nS22 = new @A @A @B @B String("Hello"); }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   300
        void test_cast3() { String tcs2 =  (@A @A String)o;      }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   301
        void test_cast4() { String tcs22 = (@A @A @B @B String)o;}
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   302
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   303
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   304
    // array levels
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   305
    static class Test3a {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   306
        Test3a(){}
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   307
        // expect 4+2+4=10
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   308
        String [][] SA_21_12c  = new  String @A @A @B [2] @A @B @B[2];
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   309
        String [][] SA_01_10c  = new  String @B [2] @A [2];
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   310
        String [][] SA_11_11c = new  String @A @B [2] @A @B [2];
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   311
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   312
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   313
    static class Test3b {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   314
        Test3b(){}
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   315
        // expect 4+2=6
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   316
        String [][] SA_22_22c  = new  String @A @A @B @B[2] @A @A @B @B[2];
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   317
        String [][] SA_20_02c  = new  String @A @A [2] @B @B[2];
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   318
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   319
    static class Test3c {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   320
        Test3c(){}
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   321
        // OK expect 4
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   322
        String @A [] @A[] SA_10_10  = new  String [2][2];
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   323
        String @A [] @B[] SA_10_01  = new  String [2][2];
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   324
        String @A @A @B[] @A @B @B [] SA_21_12  = new  String [2][2];
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   325
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   326
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   327
    static class Test3d {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   328
        Test3d(){}
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   329
        // OK expect 4
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   330
        String @A @A [] @B @B [] SA_20_02  = new  String [2][2];
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   331
        String @A @A @B @B[] @A @A @B @B [] SA_22_22  = new  String [2][2];
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   332
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   333
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   334
    // on new
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   335
    static class Test4a {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   336
        Test4a(){}
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   337
        // expect 2+2=4
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   338
        String nS_21 = new @A @A @B String("Hello");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   339
        String nS_12 = new @A @B @B String("Hello");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   340
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   341
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   342
    static class Test4b {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   343
        Test4b(){}
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   344
        // expect 1+1+2=4
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   345
        String nS20 = new @A @A String("Hello");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   346
        String nS02 = new @B @B String("Hello");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   347
        String nS22 = new @A @A @B @B String("Hello");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   348
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   349
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   350
    // Cast expressions
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   351
    static class Test5a {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   352
        Test5a(){}
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   353
        Object o = new Integer(1);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   354
        // expect 2+2=4
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   355
        Integer ci11 = (@A @B Integer)o;       // OK expect 3, got 3
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   356
        Integer ci21 = (@A @A @B Integer)o;    // OK expect 3, got 3
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   357
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   358
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   359
    static class Test5b {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   360
        Test5b(){}
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   361
        Object o = new Integer(1);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   362
        // Cast expressions
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   363
        // expect 1+2=3
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   364
        Integer ci2 =  (@A @A Integer)o;       // FAIL expect 2, got 1
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   365
        Integer ci22 = (@A @A @B @B Integer)o; // FAIL expect 3, got 1
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   366
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   367
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   368
@Retention(RUNTIME) @Target({TYPE_USE}) @Repeatable( AC.class ) @interface A { }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   369
@Retention(RUNTIME) @Target({TYPE_USE}) @Repeatable( BC.class ) @interface B { }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   370
@Retention(RUNTIME) @Target({FIELD}) @Repeatable( FC.class ) @interface F { }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   371
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AC { A[] value(); }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   372
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BC { B[] value(); }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   373
@Retention(RUNTIME) @Target({FIELD}) @interface FC { F[] value(); }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   374
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   375
}
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   376