langtools/test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest3.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: 17578
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 8005085 8005681 8008769 8010015
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    27
 * @summary Check (repeating)type annotations on lambda usage.
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
 * @run main CombinationsTargetTest3
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    30
 */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    31
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    32
import com.sun.tools.classfile.*;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    33
import java.io.File;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    34
import java.util.Vector;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    35
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    36
public class CombinationsTargetTest3 extends ClassfileTestHelper {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    37
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    38
    // Helps identify test case in event of failure.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    39
    int testcount = 0;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    40
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    41
    // Known failure cases due to open bugs.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    42
    Vector<String> skippedTests = new Vector<>();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    43
    void printSkips() {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    44
        if(!skippedTests.isEmpty()) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    45
            println(skippedTests.size() + " tests were skipped:");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    46
            for(String t : skippedTests)
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    47
                println("    " + t);
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
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    50
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    51
    // Test case descriptions and expected annotation counts.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    52
    enum srce  {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    53
        src1("type annotations on lambda expression as method arg.",4,0),
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    54
        src2("type annotations on new in single line lambda expression",2,0),
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    55
        src3("type annotations in lambda expression code block",4,0),
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    56
        src4("type annotations in code block with recursion,cast",2,0),
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    57
        src5("type annotations in lambda expression code block",4,0),
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    58
        src6("type annotations on type parm in method reference",4,0),
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    59
        src7("type annotations on inner class field of lambda expression",2,2),
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    60
        src8("type annotations in inner class of lambda expression",4,2),
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    61
        src9("type annotations on static method of interface",4,2);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    62
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    63
        String description;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    64
        // Expected annotation counts are same for Vis or Invis, but which one
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    65
        // depends on retention type.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    66
        Integer[] exp = { 0, 0 };
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    67
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    68
        // If class to test is inner class, this may be set in SourceString()
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    69
        String innerClassname = null ;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    70
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    71
        // If class to test is not main or inner class; set in sourceString()
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    72
        String altClassName = null;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    73
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    74
        srce(String desc, int e1, int e2) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    75
            description = this + ": " +desc;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    76
            exp[0]=e1;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    77
            exp[1]=e2;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    78
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    79
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    80
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    81
    // Check for RuntimeInvisible or RuntimeVisible annotations.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    82
    String[] RType={"CLASS", "RUNTIME"};
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    83
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    84
    // This can be a compile only test.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    85
    static boolean compileonly=false;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    86
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    87
    // Collect failure for end of test report()
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    88
    Vector<String> vFailures = new Vector<>();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    89
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    90
    // pass/fail determined after all tests have run.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    91
    void report() {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    92
        if(vFailures.isEmpty()) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    93
            printSkips();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    94
            println("PASS");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    95
        } else {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    96
           System.err.println("FAILED: There were failures:");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    97
           for(String f : vFailures)
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    98
               System.err.println(f);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    99
           throw new RuntimeException("There were failures. See test log.");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   100
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   101
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   102
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   103
    public static void main(String[] args) throws Exception {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   104
        if(args.length>0 && args[0].compareTo("compileonly")==0)
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   105
            compileonly=true;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   106
        new CombinationsTargetTest3().run();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   107
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   108
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   109
    void run() throws Exception {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   110
        // Determines which repeat and order in source(ABMix).
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   111
        Boolean As= false, BDs=true, ABMix=false;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   112
        int testrun=0;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   113
        // A repeats and/or B/D repeats, ABMix for order of As and Bs.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   114
        Boolean [][] bRepeat = new Boolean[][]{{false,false,false}, //no repeats
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   115
                                               {true,false,false}, //repeat @A
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   116
                                               {false,true,false}, //repeat @B
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   117
                                               {true,true,false},  //repeat both
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   118
                                               {false,false,true}  //repeat mix
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   119
        };
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   120
        // Added ElementType's. All set; not permuted (so far) for this test
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   121
        String et = "TYPE,FIELD,METHOD,PARAMETER,CONSTRUCTOR,LOCAL_VARIABLE";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   122
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   123
        // test loop
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   124
        for(Boolean[] bCombo : bRepeat) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   125
            As=bCombo[0]; BDs=bCombo[1]; ABMix=bCombo[2];
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   126
            for(srce src : srce.values())
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   127
                for( String rtype : RType ) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   128
                   switch( rtype ) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   129
                       case "RUNTIME":
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   130
                           test(0,src.exp[0],0,src.exp[1],As, BDs, ABMix,
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   131
                                "RUNTIME", et, ++testrun, src);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   132
                           break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   133
                       case "CLASS":
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   134
                           test(src.exp[0],0,src.exp[1],0,As, BDs, ABMix,
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   135
                                "CLASS", et, ++testrun, src);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   136
                           break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   137
                }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   138
            }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   139
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   140
        report();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   141
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   142
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   143
    // Filter out skipped cases, compile, pass class file to test method,
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   144
    // count annotations and asses results.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   145
    public void test(int tinv, int tvis, int inv, int vis, Boolean Arepeats,
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   146
                     Boolean BDrepeats, Boolean ABmix, String rtn, String et2,
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   147
                     Integer N, srce source) throws Exception {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   148
        ++testcount;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   149
        expected_tvisibles = tvis;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   150
        expected_tinvisibles = tinv;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   151
        expected_visibles = vis;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   152
        expected_invisibles = inv;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   153
        File testFile = null;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   154
        String tname="Test" + N.toString();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   155
        String testDef = "Test " + testcount + " parameters: tinv=" + tinv +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   156
                ", tvis=" + tvis + ", inv=" + inv + ", vis=" + vis +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   157
                ", Arepeats=" + Arepeats + ", BDrepeats=" + BDrepeats +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   158
                ", ABmix=" + ABmix + ", retention: " + rtn + ", anno2: " +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   159
                et2 + ", src=" + source;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   160
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   161
        // Skip failing cases with bug ID's
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   162
        if ((source.equals(srce.src2) || source.equals(srce.src4) ||
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   163
            source.equals(srce.src5)) &&
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   164
            (ABmix || (Arepeats && BDrepeats))) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   165
                skippedTests.add(testDef +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   166
                  "\n--8005681 repeated type-annotations on new/cast/array in" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   167
                  " inner class in lambda expression.");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   168
            return;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   169
        }//8008769 Repeated type-annotations on type parm of local variable
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   170
         else if (source.equals(srce.src6) &&
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   171
                   (ABmix || (Arepeats && BDrepeats))) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   172
            skippedTests.add(testDef +  "\n--8008769 Repeated " +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   173
                             "type-annotations on type parm of local variable");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   174
            return;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   175
        }
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
        println(testDef);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   178
        // Create test source and File.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   179
        String sourceString = sourceString(tname, rtn, et2, Arepeats,
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   180
                                           BDrepeats, ABmix, source);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   181
        testFile = writeTestFile(tname+".java", sourceString);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   182
        // Compile test source and read classfile.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   183
        File classFile = null;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   184
        try {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   185
            classFile = compile(testFile);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   186
            System.out.println("pass compile: " + tname + ".java");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   187
        } catch (Error err) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   188
            System.err.println("fail compile. Source:\n" + sourceString);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   189
            throw err;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   190
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   191
        if(!compileonly) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   192
            //check if innerClassname is set
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   193
            String classdir = classFile.getAbsolutePath();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   194
            if(source.innerClassname != null) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   195
                StringBuffer sb = new StringBuffer(classdir);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   196
                classFile=new File(sb.insert(sb.lastIndexOf(".class"),
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   197
                                   source.innerClassname).toString());
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   198
                source.innerClassname=null;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   199
            } else if (source.altClassName != null) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   200
                classdir = classdir.substring(0,classdir.lastIndexOf("Test"));
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   201
                classFile=new File(classdir.concat(source.altClassName));
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   202
                source.innerClassname=null;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   203
            }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   204
            ClassFile cf = ClassFile.read(classFile);
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
            println("Testing classfile: " + cf.getName());
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   207
            //Test class,fields and method counts.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   208
            test(cf);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   209
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   210
            for (Field f : cf.fields) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   211
                test(cf, f);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   212
                test(cf, f, true);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   213
            }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   214
            for (Method m: cf.methods) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   215
                test(cf, m);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   216
                test(cf, m, true);
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
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   219
            countAnnotations(); // sets errors=0 before counting.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   220
            if (errors > 0) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   221
                System.err.println( testDef );
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   222
                System.err.println( "Source:\n" + sourceString );
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   223
                vFailures.add(testDef);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   224
            }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   225
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   226
        if(errors==0) println("Pass"); println("");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   227
    }
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
     * Source definitions for test cases.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   231
     * To add a test:
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   232
     *   Add enum to srce(near top of file) with expected annotation counts.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   233
     *   Add source defintion below.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   234
     */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   235
    String sourceString(String testname, String retentn, String annot2,
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   236
                        Boolean Arepeats, Boolean BDrepeats, Boolean ABmix,
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   237
                        srce src) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   238
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   239
        String As = "@A", Bs = "@B", Ds = "@D";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   240
        if(Arepeats) As = "@A @A";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   241
        if(BDrepeats) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   242
            Bs = "@B @B";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   243
            Ds = "@D @D";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   244
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   245
        if(ABmix) { As = "@A @B"; Bs = "@A @B"; Ds = "@D @D"; }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   246
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   247
        // Source to check for TYPE_USE and TYPE_PARAMETER annotations.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   248
        // Source base (annotations) is same for all test cases.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   249
        String source = new String();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   250
        String imports = new String("import java.lang.annotation.*; \n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   251
            "import static java.lang.annotation.RetentionPolicy.*; \n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   252
            "import static java.lang.annotation.ElementType.*; \n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   253
            "import java.util.List; \n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   254
            "import java.util.ArrayList;\n\n");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   255
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   256
            String sourceBase = new String(
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   257
            "@Retention("+retentn+") @Target({TYPE_USE,_OTHER_}) @Repeatable( AC.class ) @interface A { }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   258
            "@Retention("+retentn+") @Target({TYPE_USE,_OTHER_}) @interface AC { A[] value(); } \n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   259
            "@Retention("+retentn+") @Target({TYPE_USE,_OTHER_}) @Repeatable( BC.class ) @interface B { }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   260
            "@Retention("+retentn+") @Target({TYPE_USE,_OTHER_}) @interface BC { B[] value(); } \n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   261
            "@Retention("+retentn+") @Target({TYPE_USE,TYPE_PARAMETER,_OTHER_}) @Repeatable(DC.class) @interface D { }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   262
            "@Retention("+retentn+") @Target({TYPE_USE,TYPE_PARAMETER,_OTHER_}) @interface DC { D[] value(); }");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   263
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   264
        // Test case sources with sample generated source
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   265
        switch(src) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   266
            case src1: //(repeating) type annotations on lambda expressions.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   267
                /*
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   268
                 * class Test1 {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   269
                 * Test1(){}
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   270
                 * interface MapFun<T,R> {  R m( T n); }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   271
                 * void meth( MapFun<String,Integer> mf ) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   272
                 *     assert( mf.m("four") == 4);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   273
                 * }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   274
                 * void test(Integer i) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   275
                 *     // lambda expression as method arg
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   276
                 *     meth( (@A @B String s) -> { @A @B Integer len = s.length(); return len; } );
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   277
                 * }}
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   278
                 */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   279
                source = new String( source +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   280
                "// " + src.description + "\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   281
                "class " + testname + " {\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   282
                "  " + testname +"(){} \n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   283
                "  interface MapFun<T,R> {  R m( T n); }\n\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   284
                "  void meth( MapFun<String,Integer> mf ) {\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   285
                "    assert( mf.m(\"four\") == 4);\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   286
                "  }\n\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   287
                "  void test(Integer i) {\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   288
                "    // lambda expression as method arg\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   289
                "    meth( (_As_ _Bs_ String s) -> { _As_ _Bs_ Integer len = s.length(); return len; } );\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   290
                "}}\n\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   291
                "\n";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   292
                break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   293
            case src2: //(repeating) type annotations on new in single line lambda expression.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   294
                /*
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   295
                 * //case2: (repeating) type annotations on new in single lambda expressions.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   296
                 * class Test2{
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   297
                 *   interface MapFun<T, R> {  R m( T n); }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   298
                 *   MapFun<Integer, String> its;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   299
                 * void test(Integer i) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   300
                 *   its = a -> "~"+new @A @B Integer(a).toString()+"~";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   301
                 *   System.out.println("in: " + i + " out: " + its.m(i));
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
                source = new String( source +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   305
                "// " + src.description + "\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   306
                "class " + testname + "{\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   307
                "  interface MapFun<T, R> {  R m( T n); }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   308
                "  MapFun<Integer, String> its;\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   309
                "  void test(Integer i) {\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   310
                "    its = a -> \"~\"+new _As_ _Bs_ Integer(a).toString()+\"~\";\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   311
                "    System.out.println(\"in: \" + i + \" out: \" + its.m(i));\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   312
                "  }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   313
                "}\n\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   314
                "\n";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   315
            break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   316
            case src3: //(repeating) type annotations in lambda expression code block.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   317
                /*
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   318
                 * class Test183{
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   319
                 *   interface MapFun<T, R> {  R m( T n); }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   320
                 *   MapFun<List<Integer>, String> iLs;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   321
                 *   void testm(Integer i) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   322
                 *       iLs = l -> { @A @B @A @B String ret = new String();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   323
                 *                    for( @A @B @A @B Integer i2 : l)
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   324
                 *                        ret=ret.concat(i2.toString() + " ");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   325
                 *                    return ret; };
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   326
                 *   List<Integer> li = new ArrayList<>();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   327
                 *   for(int j=0; j<i; j++) li.add(j);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   328
                 *   System.out.println(iLs.m(li) );
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   329
                 * }}
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   330
                 */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   331
                source = new String( source +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   332
                "// " + src.description + "\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   333
                "class "+ testname + "{\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   334
                "  interface MapFun<T, R> {  R m( T n); }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   335
                "  MapFun<List<Integer>, String> iLs;\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   336
                "  void testm(Integer i) {\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   337
                "    iLs = l -> { _As_ _Bs_ String ret = new String();\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   338
                "                 for( _As_ _Bs_ Integer i2 : l)\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   339
                "                   ret=ret.concat(i2.toString() + \" \");\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   340
                "                 return ret; };\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   341
                "  List<Integer> li = new ArrayList<>();\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   342
                "  for(int j=0; j<i; j++) li.add(j);\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   343
                "  System.out.println(iLs.m(li) );\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   344
                "}\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   345
                "\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   346
                "    public static void main(String... args) {new " + testname + "().testm(5); }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   347
                "}\n\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   348
                "\n";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   349
            break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   350
            case src4: //(repeating) type annotations in code block with recursion,cast
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   351
                /*
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   352
                 * class Test194{
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   353
                 *   interface MapFun<T, R> {  R m( T n); }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   354
                 *   MapFun<Integer, Double>  nf;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   355
                 *   void testm(Integer i) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   356
                 *       nf = j -> { return j == 1 ? 1.0 : (@A @B @A @B  Double)(nf.m(j-1) * j); };
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   357
                 *       System.out.println( "nf.m(" + i + "): " + nf.m(i));
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
                 * }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   360
                 */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   361
                source = new String( source +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   362
                "// " + src.description + "\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   363
                "class "+ testname + "{\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   364
                "  interface MapFun<T, R> {  R m( T n); }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   365
                "  MapFun<Integer, Double>  nf;\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   366
                "  void testm(Integer i) {\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   367
                "    nf = j -> { return j == 1 ? 1.0 : (_As_ _Bs_  Double)(nf.m(j-1) * j); };\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   368
                "    System.out.println( \"nf.m(\" + i + \"): \" + nf.m(i));\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   369
                "  }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   370
                "  public static void main(String... args) {new " + testname + "().testm(5); }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   371
                "}\n\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   372
                "\n";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   373
            break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   374
            case src5: //(repeating) type annotations in lambda expression code block.
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
                    * class Test180 {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   377
                    *   interface MapFun<T, R> {  R m( T n); }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   378
                    *   MapFun<Integer,List<Integer>> iLi;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   379
                    *   void test(Integer i) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   380
                    *     // type parameter use.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   381
                    *     iLi = n -> { List<@A @B @A @B Integer> LI = new ArrayList<@A @B @A @B Integer>(n);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   382
                    *                  for(int nn = n; nn >=0; nn--) LI.add(nn);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   383
                    *                  return LI; };
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   384
                    *     List<Integer> li = iLi.m(i);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   385
                    *     for(Integer k : li) System.out.print(k);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   386
                    *   }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   387
                    * }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   388
                    */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   389
                source = new String( source +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   390
                "// " + src.description + "\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   391
                "class "+ testname + "{\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   392
                "  interface MapFun<T, R> {  R m( T n); }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   393
                "  MapFun<Integer,List<Integer>> iLi;\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   394
                "  void test(Integer i) {\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   395
                "    // type parameter use.\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   396
                "    iLi = n -> { List<_As_ _Bs_ Integer> LI = new ArrayList<_As_ _Bs_ Integer>(n);\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   397
                "                 for(int nn = n; nn >=0; nn--) LI.add(nn);\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   398
                "                 return LI; };\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   399
                "    List<Integer> li = iLi.m(i);\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   400
                "    for(Integer k : li) System.out.print(k);\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   401
                "}\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   402
                "  public static void main(String... args) {new " + testname + "().test(5); }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   403
                "}\n\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:
diff changeset
   404
                "\n";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   405
            break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   406
            case src6: //(repeating) type annotations on type parm in method reference.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   407
                /*
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   408
                 * class Test240{
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   409
                 *   interface PrintString { void print(String s); }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   410
                 *   public void printArray(Object[] oa, PrintString ps) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   411
                 *       for(Object o : oa ) ps.print(o.toString());
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   412
                 *   }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   413
                 *   public void test() {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   414
                 *       Integer[] intarray = {1,2,3,4,5};
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   415
                 *       printArray(intarray, @A @B @A @B TPrint::<@A @B @A @B String>print);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   416
                 *   }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   417
                 * }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   418
                 * class TPrint {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   419
                 *    public static <T> void print(T t) { System.out.println( t.toString()); }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   420
                 * }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   421
                 */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   422
                source = new String( source +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   423
                "// " + src.description + "\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   424
                "class "+ testname + "{\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   425
                "  interface PrintString { void print(String s); }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   426
                "  public void printArray(Object[] oa, PrintString ps) {\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   427
                "      for(Object o : oa ) ps.print(o.toString());\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   428
                "  }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   429
                "  public void test() {\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   430
                "    Integer[] intarray = {1,2,3,4,5};\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   431
                "    printArray(intarray, _As_ _Bs_ TPrint::<_As_ _Bs_ String>print);\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   432
                "  }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   433
                "  public static void main(String... args) {new " + testname + "().test(); }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   434
                "}\n\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   435
                "class TPrint {\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   436
                "  public static <T> void print(T t) { System.out.println( t.toString()); }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   437
                "}\n\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   438
                "\n";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   439
            break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   440
            case src7: //(repeating)type annotations in inner class of lambda expression.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   441
                /*
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   442
                 * class Test2{
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   443
                 *   interface MapFun<T, R> {  R m( T n); }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   444
                 *   MapFun<Class<?>,String> cs;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   445
                 *   void test() {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   446
                 *     cs = c -> {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   447
                 *         class innerClass   {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   448
                 *           @A @B Class<?> icc = null;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   449
                 *           String getString() { return icc.toString(); }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   450
                 *         }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   451
                 *         return new innerClass().getString();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   452
                 *     };
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   453
                 *     System.out.println("cs.m : " + cs.m(Integer.class));
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   454
                 *   }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   455
                 * }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   456
                 */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   457
                source = new String( source +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   458
                "// " + src.description + "\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   459
                "class "+ testname + "{\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   460
                "  interface MapFun<T, R> {  R m( T n); }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   461
                "  MapFun<Class<?>,String> cs;\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   462
                "  void test() {\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   463
                "    cs = c -> {\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   464
                "        class innerClass   {\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   465
                "          _As_ _Bs_ Class<?> icc = null;\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   466
                "          innerClass(Class<?> _c) { icc = _c; }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   467
                "          String getString() { return icc.toString(); }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   468
                "        }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   469
                "        return new innerClass(c).getString();\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   470
                "    };\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   471
                "    System.out.println(\"cs.m : \" + cs.m(Integer.class));\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   472
                "  }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   473
                "\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   474
                "    public static void main(String... args) {new " + testname + "().test(); }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   475
                "}\n\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   476
                "\n";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   477
                src.innerClassname="$1innerClass";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   478
            break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   479
            case src8: //(repeating)type annotations in inner class of lambda expression.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   480
                /*
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   481
                 * class Test2{
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   482
                 *   interface MapFun<T, R> {  R m( T n); }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   483
                 *   MapFun<Class<?>,String> cs;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   484
                 *   void test() {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   485
                 *     cs = c -> {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   486
                 *         class innerClass   {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   487
                 *             Class<?> icc;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   488
                 *             innerClass(@A @B Class<?> _c) { icc = _c; }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   489
                 *             @A @B String getString() { return icc.toString(); }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   490
                 *         }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   491
                 *         return new innerClass(c).getString();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   492
                 *     };
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   493
                 *     System.out.println("cs.m : " + cs.m(Integer.class));
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   494
                 *   }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   495
                 * }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   496
                 */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   497
                source = new String( source +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   498
                "// " + src.description + "\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   499
                "class "+ testname + "{\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   500
                "  interface MapFun<T, R> {  R m( T n); }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   501
                "  MapFun<Class<?>,String> cs;\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   502
                "  void test() {\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   503
                "    cs = c -> {\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   504
                "        class innerClass {\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   505
                "            Class<?> icc;\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   506
                "            innerClass(_As_ _Bs_ Class<?> _c) { icc = _c; }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   507
                "            _As_ _Bs_ String getString() { return icc.toString(); }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   508
                "        }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   509
                "        return new innerClass(c).getString();\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   510
                "    };\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   511
                "    System.out.println(\"cs.m : \" + cs.m(Integer.class));\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   512
                "  }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   513
                "\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   514
                "    public static void main(String... args) {new " + testname + "().test(); }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   515
                "}\n\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   516
                "\n";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   517
                src.innerClassname="$1innerClass";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   518
            break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   519
            case src9: //(repeating)type annotations on static method of interface
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   520
                /*
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   521
                 *  class Test90{
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   522
                 *    interface I  {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   523
                 *      static @A @B @A @B String m() { @A @B @A @B String ret = "I.m"; return ret; }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   524
                 *    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   525
                 *  }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   526
                 */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   527
                source = new String( source +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   528
                "// " + src.description + "\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   529
                "class "+ testname + "{\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   530
                "  interface I  { \n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   531
                "    static _As_ _Bs_ String m() { _As_ _Bs_ String ret = \"I.m\"; return ret; }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   532
                "  }\n" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   533
                "}\n\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   534
                "\n";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   535
                src.innerClassname="$I";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   536
            break;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   537
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   538
        return imports + source;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   539
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   540
}