test/langtools/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest2.java
author jlahoda
Wed, 27 Nov 2019 09:00:01 +0100
changeset 59285 7799a51dbe30
parent 47216 71c04702a3d5
permissions -rw-r--r--
8231826: Implement javac changes for pattern matching for instanceof Reviewed-by: mcimadamore Contributed-by: brian.goetz@oracle.com, gavin.bierman@oracle.com, maurizio.cimadamore@oracle.com, srikanth.adayapalam@oracle.com, vicente.romero@oracle.com, jan.lahoda@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     1
/*
59285
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
     2
 * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     4
 *
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     8
 *
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    13
 * accompanied this code).
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    14
 *
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    18
 *
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    21
 * questions.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    22
 */
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    23
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    24
/*
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    25
 * @test
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    26
 * @bug 8005085 8005877 8004829 8005681 8006734 8006775 8006507
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    27
 * @summary Combinations of Target ElementTypes on (repeated)type annotations.
30846
2b3f379840f0 8074432: Move jdeps and javap to jdk.jdeps module
mchung
parents: 30730
diff changeset
    28
 * @modules jdk.jdeps/com.sun.tools.classfile
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    29
 */
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    30
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    31
import com.sun.tools.classfile.*;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    32
import java.io.File;
59285
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
    33
import java.util.List;
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    34
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    35
public class CombinationsTargetTest2 extends ClassfileTestHelper {
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    36
59285
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
    37
    private static final String JDK_VERSION =
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
    38
            Integer.toString(Runtime.getRuntime().version().feature());
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
    39
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    40
    // Test count helps identify test case in event of failure.
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    41
    int testcount = 0;
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    42
19651
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    43
    // Base test case template descriptions;true==annotations in code attribute.
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    44
    enum srce  {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    45
        src1("(repeating) type annotations on on field in method body",true),
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    46
        src2("(repeating) type annotations on type parameters, bounds and  type arguments", true),
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    47
        src3("(repeating) type annotations on type parameters of class, method return value in method", true),
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    48
        src4("(repeating) type annotations on field in anonymous class", false),
19651
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    49
        src5("(repeating) type annotations on field in anonymous class", false),
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    50
        src6("(repeating) type annotations on void method declaration", false),
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    51
        src7("(repeating) type annotations in use of instanceof", true),
59285
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
    52
        src7p("(repeating) type annotations in use of instanceof with type test pattern", true),
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
    53
        src8("(repeating) type annotations in use of instanceof in method", true),
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
    54
        src8p("(repeating) type annotations in use of instanceof with type test pattern in method", true);
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    55
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    56
        String description;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    57
        Boolean local;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    58
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    59
        srce(String desc, Boolean b) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    60
            this.description = this + ": " +desc;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    61
            this.local = b;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    62
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    63
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    64
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    65
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    66
    String[] ETypes={"TYPE", "FIELD", "METHOD", "PARAMETER", "CONSTRUCTOR",
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    67
                     "LOCAL_VARIABLE", "ANNOTATION_TYPE", "PACKAGE"};
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    68
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    69
    // local class tests will have an inner class.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    70
    Boolean hasInnerClass=false;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    71
    String innerClassname="";
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    72
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    73
    public static void main(String[] args) throws Exception {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    74
        new CombinationsTargetTest2().run();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    75
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    76
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    77
    void run() throws Exception {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    78
        // Determines which repeat and order in source(ABMix).
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    79
        Boolean As= false, BDs=true, ABMix=false;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    80
        int testrun=0;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    81
        Boolean [][] bRepeat = new Boolean[][]{{false,false,false},//no repeats
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    82
                                               {true,false,false}, //repeat @A
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    83
                                               {false,true,false}, //repeat @B
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    84
                                               {true,true,false},  //repeat both
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    85
                                               {false,false,true}  //repeat mix
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    86
        };
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    87
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    88
        for(Boolean[] bCombo : bRepeat) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    89
            As=bCombo[0]; BDs=bCombo[1]; ABMix=bCombo[2];
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    90
            for(String et : ETypes) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    91
               switch(et) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    92
                   case "METHOD":
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    93
                       test( 8, 0, 0, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, srce.src1);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    94
                       test( 0, 8, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src1);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    95
                       test( 2, 0, 2, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, srce.src5);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
    96
                       test( 0, 2, 0, 2, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src5);
19651
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    97
                       test( 0, 0, 2, 0, As, BDs, ABMix, "CLASS", et, ++testrun, srce.src6);
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    98
                       test( 0, 0, 0, 2, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src6);
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    99
                       test( 2, 0, 0, 0, As, BDs, ABMix, "CLASS", et, ++testrun, srce.src7);
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   100
                       test( 0, 2, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src7);
59285
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   101
                       test( 2, 0, 0, 0, As, BDs, ABMix, "CLASS", et, ++testrun, srce.src7p);
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   102
                       test( 0, 2, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src7p);
19651
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   103
                       test( 4, 0, 0, 0, As, BDs, ABMix, "CLASS", et, ++testrun, srce.src8);
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   104
                       test( 0, 4, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src8);
59285
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   105
                       test( 4, 0, 0, 0, As, BDs, ABMix, "CLASS", et, ++testrun, srce.src8p);
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   106
                       test( 0, 4, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src8p);
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   107
                       break;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   108
                   case "FIELD":
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   109
                       test( 8, 0, 0, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, srce.src1);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   110
                       test( 8, 0, 0, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, srce.src2);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   111
                       test( 6, 0, 0, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, srce.src3);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   112
                       test( 2, 0, 2, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, srce.src4);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   113
                       test( 0, 8, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src1);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   114
                       test( 0, 8, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src2);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   115
                       test( 0, 6, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src3);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   116
                       test( 0, 2, 0, 2, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src4);
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   117
                       break;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   118
                   default:/*TYPE,PARAMETER,LOCAL_VARIABLE,ANNOTATION_TYPE,PACKAGE*/
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   119
                       test( 0, 2, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src4);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   120
                       test( 0, 2, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src5);
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   121
                       break;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   122
               }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   123
            }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   124
        }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   125
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   126
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   127
    public void test(int tinv, int tvis, int inv, int vis, Boolean Arepeats,
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   128
                     Boolean BDrepeats, Boolean ABmix, String rtn, String et2,
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   129
                     Integer N, srce source) throws Exception {
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   130
        ++testcount;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   131
        expected_tvisibles = tvis;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   132
        expected_tinvisibles = tinv;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   133
        expected_visibles = vis;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   134
        expected_invisibles = inv;
59285
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   135
        extraOptions = List.of();
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   136
        File testFile = null;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   137
        String tname="Test" + N.toString();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   138
        hasInnerClass=false;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   139
        String testDef = "Test " + testcount + " parameters: tinv=" + tinv +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   140
                ", tvis=" + tvis + ", inv=" + inv + ", vis=" + vis +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   141
                ", Arepeats=" + Arepeats + ", BDrepeats=" + BDrepeats +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   142
                ", ABmix=" + ABmix + ", retention: " + rtn + ", anno2: " +
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   143
                et2 + ", src=" + source + "\n    " + source.description;
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   144
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   145
        println(testDef);
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   146
        // Create test source and File.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   147
        String sourceString = sourceString(tname, rtn, et2, Arepeats,
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   148
                                           BDrepeats, ABmix, source);
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   149
        testFile = writeTestFile(tname+".java", sourceString);
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   150
        // Compile test source and read classfile.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   151
        File classFile = null;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   152
        try {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   153
            classFile = compile(testFile);
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   154
        } catch (Error err) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   155
            System.err.println("Failed compile. Source:\n" + sourceString);
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   156
            throw err;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   157
        }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   158
        //if sourcString() set hasInnerClass it also set innerClassname.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   159
        if(hasInnerClass) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   160
            StringBuffer sb = new StringBuffer(classFile.getAbsolutePath());
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   161
            classFile=new File(sb.insert(sb.lastIndexOf(".class"),innerClassname).toString());
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   162
            println("classfile: " + classFile.getAbsolutePath());
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   163
        }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   164
        ClassFile cf = ClassFile.read(classFile);
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   165
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   166
        //Test class,fields and method counts.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   167
        test(cf);
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   168
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   169
        for (Field f : cf.fields) {
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   170
            if(source.local)
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   171
                test(cf, f, true);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   172
            else
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   173
                test(cf,f);
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   174
        }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   175
        for (Method m: cf.methods) {
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   176
            if(source.local)
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   177
                test(cf, m, true);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   178
            else
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   179
                test(cf, m);
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   180
        }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   181
        countAnnotations();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   182
        if (errors > 0) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   183
            System.err.println( testDef );
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   184
            System.err.println( "Source:\n" + sourceString );
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   185
            throw new Exception( errors + " errors found" );
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   186
        }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   187
        println("Pass");
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   188
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   189
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   190
    // Source for test cases
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   191
    String sourceString(String testname, String retentn, String annot2,
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   192
                        Boolean Arepeats, Boolean BDrepeats, Boolean ABmix,
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   193
                        srce src) {
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   194
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   195
        String As = "@A", Bs = "@B", Ds = "@D";
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   196
        if(Arepeats) As = "@A @A";
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   197
        if(BDrepeats) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   198
            Bs = "@B @B";
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   199
            Ds = "@D @D";
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   200
        }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   201
        if(ABmix) { As = "@A @B"; Bs = "@A @B"; Ds = "@D @D"; }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   202
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   203
        // Source to check for TYPE_USE and TYPE_PARAMETER annotations.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   204
        // Source base (annotations) is same for all test cases.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   205
        String source = new String();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   206
        String imports = new String("import java.lang.annotation.*; \n" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   207
            "import static java.lang.annotation.RetentionPolicy.*; \n" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   208
            "import static java.lang.annotation.ElementType.*; \n" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   209
            "import java.util.List; \n" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   210
            "import java.util.HashMap; \n" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   211
            "import java.util.Map; \n\n");
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   212
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   213
            String sourceBase = new String("@Retention("+retentn+")\n" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   214
            "@Target({TYPE_USE,_OTHER_})\n" +
15554
eea02af8112f 8007313: Remove use of {ContainerFor/ContainedBy} from langtools
darcy
parents: 15385
diff changeset
   215
            "@Repeatable( AC.class )\n" +
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   216
            "@interface A { }\n\n" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   217
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   218
            "@Retention("+retentn+")\n" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   219
            "@Target({TYPE_USE,_OTHER_})\n" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   220
            "@interface AC { A[] value(); }\n\n" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   221
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   222
            "@Retention("+retentn+")\n" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   223
            "@Target({TYPE_USE,_OTHER_})\n" +
15554
eea02af8112f 8007313: Remove use of {ContainerFor/ContainedBy} from langtools
darcy
parents: 15385
diff changeset
   224
            "@Repeatable( BC.class )\n" +
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   225
            "@interface B { }\n\n" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   226
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   227
            "@Retention("+retentn+")\n" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   228
            "@Target({TYPE_USE,_OTHER_})\n" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   229
            "@interface BC { B[] value(); } \n\n" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   230
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   231
            "@Retention("+retentn+")\n" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   232
            "@Target({TYPE_USE,TYPE_PARAMETER,_OTHER_})\n" +
15554
eea02af8112f 8007313: Remove use of {ContainerFor/ContainedBy} from langtools
darcy
parents: 15385
diff changeset
   233
            "@Repeatable(DC.class)\n" +
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   234
            "@interface D { }\n\n" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   235
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   236
            "@Retention("+retentn+")\n" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   237
            "@Target({TYPE_USE,TYPE_PARAMETER,_OTHER_})\n" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   238
            "@interface DC { D[] value(); }\n\n");
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   239
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   240
        // Test case sources with sample generated source
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   241
        switch(src) {
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   242
            case src1: // (repeating) type annotations on field in method body
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   243
                    /*
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   244
                     * class Test1 {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   245
                     * Test1(){}
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   246
                     * // type usage in method body
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   247
                     * String test(Test1 this, String param, String ... vararg) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   248
                     *     @A @B
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   249
                     *     Object o = new @A @B  String @A @B  [3];
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   250
                     *         return (@A @B  String) null;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   251
                     * }}
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   252
                      */
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   253
                source = new String(
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   254
                    "// " + src.description + "\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   255
                    "class " + testname + " {\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   256
                    "" + testname +"(){} \n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   257
                    "// type usage in method body \n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   258
                    "String test("+testname+" this, " +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   259
                       "String param, String ... vararg) { \n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   260
                    "    _As_ _Bs_\n    Object o = new _As_ _Bs_  String _As_ _Bs_  [3]; \n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   261
                    "        return (_As_ _Bs_  String) null; \n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   262
                    "} \n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   263
                    "} \n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   264
                    "\n\n";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   265
                    break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   266
            case src2: // (repeating) annotations on type parameters, bounds and  type arguments in new statement.
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   267
                    /*
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   268
                     * class Test2<T extends Object> {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   269
                     *     Map<List<String>, Integer> map =
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   270
                     *         new HashMap<@A @B List<@A @B String>, @A @B Integer>();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   271
                     *     Map<List<String>, Integer> map2 = new @A @B HashMap<>();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   272
                     *     String test(Test2<T> this) { return null;}
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   273
                     *     <T> String genericMethod(T t) { return null; }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   274
                     * }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   275
                     */
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   276
                source = new String( source +
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   277
                    "// " + src.description + "\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   278
                    "class " + testname + "<T extends Object> {\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   279
                    "    Map<List<String>, Integer> map =\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   280
                    "        new HashMap<_As_ _Bs_ List<_As_ _Bs_ String>, _As_ _Bs_ Integer>();\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   281
                    "    Map<List<String>, Integer> map2 = new _As_ _Bs_ HashMap<>();\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   282
                    "    String test(" + testname + "<T> this) { return null;}\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   283
                    "    <T> String genericMethod(T t) { return null; }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   284
                    "}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   285
                    "\n\n";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   286
                break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   287
            case src3: // (repeating)annotations on type parameters of class, method return value in method.
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   288
                    /*
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   289
                     * class Test3{
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   290
                     *     <E extends Comparable> Map<List<E>, E > foo(E e) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   291
                     *         class maptest <E> {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   292
                     *             Map<List<E>,E> getMap() {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   293
                     *                 Map<List<E>,E> Em = new HashMap<List<@A @B @D E>,@A @B @D E>();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   294
                     *                 return Em;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   295
                     *             }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   296
                     *         }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   297
                     *         return new maptest<E>().getMap();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   298
                     *    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   299
                     *    Map<List<String>,String> shm = foo(new String("hello"));
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   300
                     * }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   301
                     */
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   302
                source = new String( source +
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   303
                    "// " + src.description + "\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   304
                    "class "+ testname + "{\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   305
                    "    <E extends Comparable> Map<List<E>, E > foo(E e) {\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   306
                    "        class maptest <E> {\n" +                  // inner class $1maptest
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   307
                    "            Map<List<E>,E> getMap() { \n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   308
                    "                Map<List<E>,E> Em = new HashMap<List<_As_ _Bs_ _Ds_ E>,_As_ _Bs_ _Ds_ E>();\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   309
                    "                return Em;\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   310
                    "            }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   311
                    "        }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   312
                    "        return new maptest<E>().getMap();\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   313
                    "   }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   314
                    "   Map<List<String>,String> shm = foo(new String(\"hello\"));\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   315
                    "}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs).replace("_Ds_",Ds) +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   316
                    "\n\n";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   317
                    hasInnerClass=true;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   318
                    innerClassname="$1maptest";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   319
                break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   320
            case src4: // (repeating)annotations on field in anonymous class
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   321
                    /*
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   322
                     * class Test95{
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   323
                     *     void mtest( Test95 t){  }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   324
                     *     public void test() {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   325
                     *         mtest( new Test95() {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   326
                     *             @A @A @B @B String data2 = "test";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   327
                     *         });
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   328
                     *     }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   329
                     * }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   330
                     */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   331
                source = new String( source +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   332
                    "// " + src.description + "\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   333
                    "class "+ testname + "{\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   334
                    "    void mtest( "+ testname + " t){  }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   335
                    "    public void test() {\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   336
                    "        mtest( new "+ testname + "() {\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   337
                    "            _As_ _Bs_ String data2 = \"test\";\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   338
                    "        });\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   339
                    "    }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   340
                    "}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   341
                    "\n\n";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   342
                    hasInnerClass=true;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   343
                    innerClassname="$1";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   344
                break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   345
            case src5: // (repeating)annotations on method in anonymous class
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   346
                    /*
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   347
                     * class Test120{
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   348
                     *     void mtest( Test120 t){  }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   349
                     *     public void test() {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   350
                     *         mtest( new Test120() {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   351
                     *             @A @B @A @B String m2(){return null;};
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   352
                     *         });
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   353
                     *     }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   354
                     */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   355
                source = new String( source +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   356
                    "// " + src.description + "\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   357
                    "class "+ testname + "{\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   358
                    "    void mtest( "+ testname + " t){  }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   359
                    "    public void test() {\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   360
                    "        mtest( new "+ testname + "() {\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   361
                    "            _As_ _Bs_ String m2(){return null;};\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   362
                    "        });\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   363
                    "    }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   364
                    "}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   365
                    "\n\n";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   366
                    hasInnerClass=true;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   367
                    innerClassname="$1";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 17544
diff changeset
   368
                break;
19651
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   369
            case src6: // (repeating)annotations on void method declaration
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   370
                    /*
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   371
                     * class Test95{
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   372
                     *     @A @A @B @B public void test() { };
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   373
                     * }
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   374
                     */
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   375
                source = new String( source +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   376
                    "// " + src.description + "\n" +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   377
                    "class "+ testname + "{\n" +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   378
                    "    _As_ _Bs_ public void test() { }\n" +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   379
                    "}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   380
                    "\n\n";
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   381
                    hasInnerClass=false;
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   382
                break;
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   383
            case src7: // (repeating) type annotations in use of instanceof
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   384
                    /*
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   385
                     *   class Test10{
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   386
                     *       String data = "test";
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   387
                     *       boolean dataIsString = ( data instanceof @A @B @A @B String);
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   388
                     *   }
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   389
                     */
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   390
                source = new String( source +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   391
                    "// " + src.description + "\n" +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   392
                    "class "+ testname + "{\n" +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   393
                    "    String data = \"test\";\n" +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   394
                    "    boolean dataIsString = ( data instanceof _As_ _Bs_ String);\n" +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   395
                    "}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   396
                    "\n\n";
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   397
                    hasInnerClass=false;
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   398
                break;
59285
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   399
            case src7p: // (repeating) type annotations in use of instanceof with type test pattern
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   400
                    /*
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   401
                     *   class Test10{
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   402
                     *       String data = "test";
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   403
                     *       boolean dataIsString = ( data instanceof @A @B @A @B String str);
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   404
                     *   }
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   405
                     */
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   406
                source = new String( source +
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   407
                    "// " + src.description + "\n" +
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   408
                    "class "+ testname + "{\n" +
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   409
                    "    String data = \"test\";\n" +
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   410
                    "    boolean dataIsString = ( data instanceof _As_ _Bs_ String str && str.isEmpty());\n" +
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   411
                    "}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   412
                    "\n\n";
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   413
                extraOptions = List.of("--enable-preview",
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   414
                                       "-source", JDK_VERSION);
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   415
                hasInnerClass=false;
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   416
                break;
19651
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   417
            case src8: // (repeating) type annotations in use of instanceof
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   418
                    /*
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   419
                     *   class Test20{
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   420
                     *       String data = "test";
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   421
                     *       Boolean isString() {
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   422
                     *           if( data instanceof @A @B @A @B String )
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   423
                     *               return true;
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   424
                     *           else
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   425
                     *               return( data instanceof @A @B @A @B String );
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   426
                     *       }
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   427
                     *   }
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   428
                     */
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   429
                source = new String( source +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   430
                    "// " + src.description + "\n" +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   431
                    "class "+ testname + "{\n" +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   432
                    "    String data = \"test\";\n" +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   433
                    "    Boolean isString() { \n" +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   434
                    "        if( data instanceof _As_ _Bs_ String )\n" +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   435
                    "            return true;\n" +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   436
                    "        else\n" +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   437
                    "            return( data instanceof _As_ _Bs_ String );\n" +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   438
                    "    }\n" +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   439
                    "}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   440
                    "\n\n";
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   441
                    hasInnerClass=false;
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   442
                break;
59285
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   443
            case src8p: // (repeating) type annotations in use of instanceof with type test pattern
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   444
                   /*
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   445
                     *   class Test20{
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   446
                     *       String data = "test";
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   447
                     *       Boolean isString() {
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   448
                     *           if( data instanceof @A @B @A @B String )
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   449
                     *               return true;
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   450
                     *           else
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   451
                     *               return( data instanceof @A @B @A @B String );
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   452
                     *       }
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   453
                     *   }
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   454
                     */
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   455
                source = new String( source +
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   456
                    "// " + src.description + "\n" +
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   457
                    "class "+ testname + "{\n" +
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   458
                    "    String data = \"test\";\n" +
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   459
                    "    Boolean isString() { \n" +
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   460
                    "        if( data instanceof _As_ _Bs_ String str)\n" +
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   461
                    "            return true;\n" +
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   462
                    "        else\n" +
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   463
                    "            return( data instanceof _As_ _Bs_ String str && str.isEmpty());\n" +
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   464
                    "    }\n" +
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   465
                    "}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   466
                    "\n\n";
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   467
                extraOptions = List.of("--enable-preview",
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   468
                                       "-source", JDK_VERSION);
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   469
                hasInnerClass=false;
7799a51dbe30 8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents: 47216
diff changeset
   470
                break;
19651
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   471
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   472
        }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   473
        return imports + source;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   474
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   475
}