langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/ClassCase.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.HashSet;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    28
import java.util.List;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    29
import java.util.Map;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    30
import java.util.Set;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    31
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
 *
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    34
 * @author Robert Field
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
public class ClassCase {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    37
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    38
    public enum Kind {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    39
        IVAC        (true,  "v"),
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    40
        IPRESENT    (true,  "p"),
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    41
        IDEFAULT    (true,  "d"),
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    42
        CNONE       (false, "n"),
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    43
        CABSTRACT   (false, "a"),
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    44
        CCONCRETE   (false, "c");
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    45
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    46
        private final String prefix;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    47
        public final boolean isInterface;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    48
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    49
        Kind(boolean isInterface, String prefix) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    50
            this.isInterface = isInterface;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    51
            this.prefix = prefix;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    52
        }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    53
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    54
        public String getPrefix() { return prefix; }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    55
    }
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
    public final Kind kind;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    58
    private final ClassCase superclass;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    59
    private final List<ClassCase> supertypes;
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
    private String name;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    62
    private boolean _OK;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    63
    private boolean _HasClassMethod;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    64
    private Set<ClassCase> _mprov;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    65
    private boolean _IsConcrete;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    66
    private boolean _HasDefault;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    67
    private ClassCase _mres;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    68
    private ClassCase _mdefend;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    69
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    70
    private Set<RuleGroup> executed = new HashSet<RuleGroup>();
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    71
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    72
    public ClassCase(Kind kind, ClassCase superclass, List<ClassCase> interfaces) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    73
        this.kind = kind;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    74
        this.superclass = superclass;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    75
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    76
        // Set supertypes from superclass (if any) and interfaces
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    77
        List<ClassCase> lc;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    78
        if (superclass == null) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    79
            lc = interfaces;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    80
        } else {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    81
            lc = new ArrayList<>();
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    82
            lc.add(superclass);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    83
            lc.addAll(interfaces);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    84
        }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    85
        this.supertypes = lc;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    86
    }
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
    public final boolean isInterface() { return kind.isInterface; }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    89
    public final boolean isClass() { return !kind.isInterface; }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    90
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    91
    public Set<ClassCase> get_mprov() {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    92
        exec(RuleGroup.PROVENENCE);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    93
        return _mprov;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    94
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    95
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    96
    public void set_mprov(ClassCase cc) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    97
        Set<ClassCase> s = new HashSet<>();
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    98
        s.add(cc);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
    99
        _mprov = s;
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
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   102
    public void set_mprov(Set<ClassCase> s) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   103
        _mprov = s;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   104
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   105
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   106
    public ClassCase get_mres() {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   107
        exec(RuleGroup.RESOLUTION);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   108
        return _mres;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   109
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   110
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   111
    public void set_mres(ClassCase cc) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   112
        _mres = cc;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   113
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   114
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   115
    public ClassCase get_mdefend() {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   116
        exec(RuleGroup.DEFENDER);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   117
        return _mdefend;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   118
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   119
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   120
    public void set_mdefend(ClassCase cc) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   121
        _mdefend = cc;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   122
    }
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
    public boolean get_HasClassMethod() {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   125
        exec(RuleGroup.PROVENENCE);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   126
        return _HasClassMethod;
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
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   129
    public void set_HasClassMethod(boolean bool) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   130
        _HasClassMethod = bool;
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
    public boolean get_HasDefault() {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   134
        exec(RuleGroup.MARKER);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   135
        return _HasDefault;
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
    public void set_HasDefault(boolean bool) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   139
        _HasDefault = bool;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   140
    }
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
    public boolean get_IsConcrete() {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   143
        exec(RuleGroup.MARKER);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   144
        return _IsConcrete;
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
    public void set_IsConcrete(boolean bool) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   148
        _IsConcrete = bool;
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
    public boolean get_OK() {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   152
        exec(RuleGroup.CHECKING);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   153
        return _OK;
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
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   156
    public void set_OK(boolean bool) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   157
        _OK = bool;
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
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   160
    public boolean isMethodDefined() {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   161
        for (ClassCase cc : supertypes) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   162
            if (cc.isMethodDefined()) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   163
                return true;
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
        }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   166
        switch (kind) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   167
            case CCONCRETE:
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   168
            case CABSTRACT:
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   169
            case IPRESENT:
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   170
            case IDEFAULT:
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   171
                return true;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   172
            default:
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   173
                return false;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   174
        }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   175
    }
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
    public boolean isAbstract() {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   178
        return isMethodDefined() && (get_mres()==null);
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
    public boolean hasSuperclass() {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   182
        return superclass != null;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   183
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   184
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   185
    public ClassCase getSuperclass() {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   186
        return superclass;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   187
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   188
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   189
    public List<ClassCase> getSupertypes() {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   190
        return supertypes;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   191
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   192
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   193
    public List<ClassCase> getInterfaces() {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   194
        if (superclass != null) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   195
            if (supertypes.get(0) != superclass) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   196
                throw new AssertionError("superclass missing from supertypes");
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   197
            }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   198
            return supertypes.subList(1, supertypes.size());
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   199
        } else {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   200
            return supertypes;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   201
        }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   202
    }
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
    public boolean isSubtypeOf(ClassCase cc) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   205
        // S-Refl
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   206
        if (cc.equals(this)) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   207
            return true;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   208
        }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   209
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   210
        // S-Def
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   211
        for (ClassCase sp : getSupertypes()) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   212
            if (cc.equals(sp)) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   213
                return true;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   214
            }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   215
        }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   216
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   217
        // _S-Trans
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   218
        for (ClassCase sp : getSupertypes()) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   219
            if (sp.isSubtypeOf(cc)) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   220
                return true;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   221
            }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   222
        }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   223
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   224
        return false;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   225
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   226
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   227
    public void init(Map<String, Integer> namingContext) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   228
        if (name != null) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   229
            return; // Already inited
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   230
        }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   231
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   232
        for (ClassCase sup : supertypes) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   233
            sup.init(namingContext);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   234
        }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   235
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   236
        // Build name
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   237
        StringBuilder sb = new StringBuilder();
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   238
        if (!supertypes.isEmpty()) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   239
            sb.append(isInterface() ? "I" : "C");
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   240
            for (ClassCase cc : supertypes) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   241
                sb.append(cc.getName());
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   242
            }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   243
            sb.append(kind.isInterface ? "i" : "c");
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   244
        }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   245
        sb.append(kind.prefix);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   246
        String pname = sb.toString();
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   247
        Integer icnt = namingContext.get(pname);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   248
        int cnt = icnt == null ? 0 : icnt;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   249
        ++cnt;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   250
        namingContext.put(pname, cnt);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   251
        if (cnt > 1) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   252
            sb.append(cnt);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   253
        }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   254
        this.name = sb.toString();
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   255
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   256
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   257
    public boolean isa(Kind... kinds) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   258
        for (Kind k : kinds) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   259
            if (kind == k) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   260
                return true;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   261
            }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   262
        }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   263
        return false;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   264
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   265
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   266
    private void exec(RuleGroup rg ) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   267
        if (!executed.contains(rg)) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   268
            rg.exec(this);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   269
            executed.add(rg);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   270
        }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   271
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   272
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   273
    public void collectClasses(Set<ClassCase> seen) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   274
        seen.add(this);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   275
        for (ClassCase cc : supertypes) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   276
            cc.collectClasses(seen);
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   277
        }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   278
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   279
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   280
    public String getID() {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   281
        if (name == null) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   282
            throw new Error("Access to uninitialized ClassCase");
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   283
        } else {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   284
            return name;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   285
        }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   286
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   287
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   288
    public final String getName() {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   289
        if (name == null) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   290
            return "ClassCase uninited@" + hashCode();
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   291
        } else {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   292
            return name;
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   293
        }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   294
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   295
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   296
    @Override
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   297
    public boolean equals(Object obj) {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   298
        return obj instanceof ClassCase && getID().equals(((ClassCase)obj).getID());
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   299
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   300
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   301
    @Override
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   302
    public int hashCode() {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   303
        return getID().hashCode();
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   304
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   305
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   306
    @Override
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   307
    public String toString() {
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   308
        return getName();
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   309
    }
4e29b285c723 8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff changeset
   310
}