langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/Hierarchy.java
author alundblad
Wed, 26 Aug 2015 09:02:02 +0200
changeset 32337 c9d3ab9f601c
parent 14554 4e29b285c723
permissions -rw-r--r--
8133671: langtools tests have bad license Summary: Dropped classpath exception from copyright notice in tests. Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14554
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
     1
/*
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
     4
 *
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
32337
c9d3ab9f601c 8133671: langtools tests have bad license
alundblad
parents: 14554
diff changeset
     7
 * published by the Free Software Foundation.
14554
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
     8
 *
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    13
 * accompanied this code).
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    14
 *
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    18
 *
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    21
 * questions.
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    22
 */
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    23
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    24
package org.openjdk.tests.shapegen;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    25
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    26
import java.util.ArrayList;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    27
import java.util.List;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    28
import java.util.HashMap;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    29
import java.util.HashSet;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    30
import java.util.Map;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    31
import java.util.Set;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    32
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    33
import static org.openjdk.tests.shapegen.ClassCase.Kind.*;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    34
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    35
/**
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    36
 *
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    37
 * @author Robert Field
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    38
 */
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    39
public class Hierarchy {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    40
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    41
    public final ClassCase root;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    42
    public final Set<ClassCase> all;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    43
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    44
    public Hierarchy(ClassCase root) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    45
        this.root = root;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    46
        root.init(new HashMap<String,Integer>());
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    47
        Set<ClassCase> allClasses = new HashSet<>();
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    48
        root.collectClasses(allClasses);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    49
        this.all = allClasses;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    50
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    51
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    52
    public boolean anyDefaults() {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    53
        for (ClassCase cc : all) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    54
            if (cc.kind == IDEFAULT) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    55
                return true;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    56
            }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    57
        }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    58
        return false;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    59
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    60
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    61
    public boolean get_OK() {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    62
        return root.get_OK();
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    63
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    64
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    65
    public String testName() {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    66
        return root + "Test";
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    67
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    68
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    69
    private static void genInterfaceList(StringBuilder buf, String prefix, List<ClassCase> interfaces) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    70
            if (!interfaces.isEmpty()) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    71
                buf.append(" ");
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    72
                buf.append(prefix);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    73
                buf.append(" ");
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    74
                buf.append(interfaces.get(0));
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    75
                for (int i = 1; i < interfaces.size(); ++i) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    76
                    buf.append(", " + interfaces.get(i));
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    77
                }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    78
            }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    79
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    80
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    81
    public static void genClassDef(StringBuilder buf, ClassCase cc, String implClass, List<ClassCase> defaultRef) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    82
        if (cc.isInterface()) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    83
            buf.append("interface ");
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    84
            buf.append(cc.getName() + " ");
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    85
            genInterfaceList(buf, "extends", cc.getInterfaces());
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    86
            buf.append(" {\n");
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    87
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    88
            switch (cc.kind) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    89
                case IDEFAULT:
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    90
                    buf.append("    default String m() { return \"\"; }\n");
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    91
                    defaultRef.add(cc);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    92
                    break;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    93
                case IPRESENT:
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    94
                    buf.append("    String m();\n");
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    95
                    break;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    96
                case IVAC:
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    97
                    break;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    98
                default:
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    99
                    throw new AssertionError("Unexpected kind");
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   100
            }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   101
            buf.append("}\n\n");
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   102
        } else {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   103
            buf.append((cc.isAbstract()? "abstract " : ""));
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   104
            buf.append(" class " + cc.getName());
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   105
            if (cc.getSuperclass() != null) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   106
                buf.append(" extends " + cc.getSuperclass());
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   107
            }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   108
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   109
            genInterfaceList(buf, "implements", cc.getInterfaces());
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   110
            buf.append(" {\n");
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   111
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   112
            switch (cc.kind) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   113
                case CCONCRETE:
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   114
                    buf.append("   public String m() { return \"\"; }\n");
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   115
                    break;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   116
                case CABSTRACT:
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   117
                    buf.append("   public abstract String m();\n");
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   118
                    break;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   119
                case CNONE:
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   120
                    break;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   121
                default:
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   122
                    throw new AssertionError("Unexpected kind");
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   123
            }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   124
            buf.append("}\n\n");
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   125
        }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   126
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   127
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   128
    @Override
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   129
    public boolean equals(Object obj) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   130
        return obj instanceof Hierarchy && root.getID().equals(((Hierarchy)obj).root.getID());
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   131
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   132
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   133
    @Override
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   134
    public int hashCode() {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   135
        return root.getID().hashCode();
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   136
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   137
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   138
    @Override
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   139
    public String toString() {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   140
        return root.getName();
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   141
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   142
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   143
    private static String classNames[] = {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   144
        "C", "D", "E", "F", "G", "H", "S", "T", "U", "V"
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   145
    };
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   146
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   147
    private static String interfaceNames[] = {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   148
        "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R"
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   149
    };
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   150
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   151
    private static int CLASS_INDEX = 0;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   152
    private static int INTERFACE_INDEX = 1;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   153
    private static int NUM_INDICIES = 2;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   154
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   155
    public List<String> getDescription() {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   156
        Map<ClassCase,String> nameMap = new HashMap<>();
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   157
        assignNames(root, new int[NUM_INDICIES], nameMap);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   158
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   159
        ArrayList<String> res = new ArrayList<>();
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   160
        if (root.getSupertypes().size() == 0) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   161
           res.add(nameMap.get(root) + root.kind.getPrefix() + "()");
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   162
        } else {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   163
            genCaseDescription(root, res, new HashSet<ClassCase>(), nameMap);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   164
        }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   165
        return res;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   166
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   167
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   168
    private static void assignNames(
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   169
            ClassCase cc, int indices[], Map<ClassCase,String> names) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   170
        String name = names.get(cc);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   171
        if (name == null) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   172
            if (cc.isInterface()) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   173
                names.put(cc, interfaceNames[indices[INTERFACE_INDEX]++]);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   174
            } else {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   175
                names.put(cc, classNames[indices[CLASS_INDEX]++]);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   176
            }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   177
            for (int i = 0; i < cc.getSupertypes().size(); ++i) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   178
                assignNames(cc.getSupertypes().get(i), indices, names);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   179
            }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   180
        }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   181
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   182
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   183
    private static void genCaseDescription(
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   184
            ClassCase cc, List<String> res, Set<ClassCase> alreadyDone,
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   185
            Map<ClassCase,String> nameMap) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   186
        if (!alreadyDone.contains(cc)) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   187
            if (cc.getSupertypes().size() > 0) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   188
                StringBuilder sb = new StringBuilder();
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   189
                sb.append(nameMap.get(cc));
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   190
                sb.append(cc.kind.getPrefix());
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   191
                sb.append("(");
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   192
                for (int i = 0; i < cc.getSupertypes().size(); ++i) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   193
                    ClassCase supertype = cc.getSupertypes().get(i);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   194
                    if (i != 0) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   195
                        sb.append(",");
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   196
                    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   197
                    genCaseDescription(supertype, res, alreadyDone, nameMap);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   198
                    sb.append(nameMap.get(supertype));
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   199
                    sb.append(supertype.kind.getPrefix());
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   200
                }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   201
                sb.append(")");
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   202
                res.add(sb.toString());
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   203
            }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   204
        }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   205
        alreadyDone.add(cc);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   206
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   207
}