test/hotspot/jtreg/vmTestbase/nsk/share/Denotation.java
author phh
Sat, 30 Nov 2019 14:33:05 -0800
changeset 59330 5b96c12f909d
parent 49934 44839fbb20db
permissions -rw-r--r--
8234541: C1 emits an empty message when it inlines successfully Summary: Use "inline" as the message when successfull Reviewed-by: thartmann, mdoerr Contributed-by: navy.xliu@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49934
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
     1
/*
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
     2
 * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
     4
 *
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
     7
 * published by the Free Software Foundation.
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
     8
 *
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    13
 * accompanied this code).
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    14
 *
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    18
 *
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    21
 * questions.
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    22
 */
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    23
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    24
package nsk.share;
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    25
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    26
import java.util.*;
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    27
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    28
/**
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    29
 * Denotation implies a pair of algorithms for naming and
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    30
 * indexing of some objects.
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    31
 *
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    32
 * <p>No matter what kind of objects, just make sure that:
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    33
 * <ul>
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    34
 * <li><tt>indexFor(nameFor(index))</tt> equals to <tt>index</tt>
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    35
 * </li>
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    36
 * <li><tt>nameFor(indexFor(name))</tt> is equivalent to <tt>name</tt>
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    37
 * </li>
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    38
 * </ul>
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    39
 *
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    40
 * <p>The notions of indeces equality and names equivalence
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    41
 * are formalized by the methods <tt>equality()</tt> and
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    42
 * <tt>equivalence()</tt> correspondingly.
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    43
 *
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    44
 * <p>For better understanding of Denotation, you may want to
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    45
 * see the TreeNodesDenotation class as an implementation example.
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    46
 *
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    47
 * @see #equality(int[],int[])
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    48
 * @see #equivalence(String,String)
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    49
 * @see TreeNodesDenotation
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    50
 */
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    51
abstract public class Denotation {
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    52
    /**
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    53
     * Check if the <tt>name</tt> is legal, and return the
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    54
     * numeric index for that object denoted by the given
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    55
     * <tt>name</tt>.
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    56
     *
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    57
     * @throws IllegalArgumentException If the <tt>name</tt>
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    58
     * is illegal.
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    59
     */
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    60
    abstract public int[] indexFor(String name);
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    61
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    62
    /**
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    63
     * Check if the <tt>index[]</tt> is legal, and return
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    64
     * a symbolic name for the object denoted by the given
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    65
     * <tt>index[]</tt>.
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    66
     *
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    67
     * @throws IllegalArgumentException If the <tt>index[]</tt>
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    68
     * is illegal.
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    69
     */
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    70
    abstract public String nameFor(int[] index);
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    71
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    72
    /**
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    73
     * Re-call to <tt>nameFor(int[])</tt> with the 1-element
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    74
     * array <tt>{i}</tt> as the <tt>index</tt> argument.
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    75
     *
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    76
     * @see #nameFor(int[])
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    77
     */
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    78
    public String nameFor(int i) {
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    79
        return nameFor(new int[] { i });
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    80
    }
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    81
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    82
    /**
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    83
     * Re-call to <tt>nameFor(int[])</tt> with the 2-elements
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    84
     * array <tt>{i0,i1}</tt> as the <tt>index</tt> argument.
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    85
     *
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    86
     * @see #nameFor(int[])
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    87
     */
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    88
    public String nameFor(int i0, int i1) {
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    89
        return nameFor(new int[] {i0, i1});
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    90
    }
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    91
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    92
    /**
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    93
     * Re-call to <tt>nameFor(int[])</tt> with the 3-elements
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    94
     * array <tt>{i0,i1,i2}</tt> as the <tt>index</tt> argument.
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    95
     *
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    96
     * @see #nameFor(int[])
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    97
     */
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    98
    public String nameFor(int i0, int i1, int i2) {
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
    99
        return nameFor(new int[] {i0, i1, i2});
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   100
    }
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   101
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   102
    /**
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   103
     * Indeces equality means equality of objects they denote.
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   104
     *
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   105
     * <p>Indeces <tt>index1[]</tt> and <tt>index2[]</tt> are
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   106
     * equal, if they are equal as <tt>int[]</tt> arrays. But,
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   107
     * there is no index equal to <tt>null</tt>; particularly,
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   108
     * <tt>null</tt> is not equal to itself.
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   109
     *
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   110
     * @see Arrays#equals(int[],int[])
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   111
     */
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   112
    public boolean equality(int[] index1, int[] index2) {
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   113
        if (index1 == null || index2 == null)
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   114
            return false;
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   115
        return Arrays.equals(index1,index2);
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   116
    }
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   117
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   118
    /**
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   119
     * Names equivalence means equality of objects they denote.
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   120
     *
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   121
     * <p>Strings <tt>name1</tt> and <tt>name2</tt> are equivalent,
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   122
     * if correspondent indeces are equal. There is no <tt>name</tt>
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   123
     * equivalent to <tt>null</tt>; particularly, <tt>null</tt> is
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   124
     * not equivalent to itself.
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   125
     *
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   126
     * @see #equality(int[],int[])
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   127
     */
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   128
    public boolean equivalence(String name1, String name2) {
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   129
        if (name1 == null || name2 == null)
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   130
            return false;
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   131
        return equality(indexFor(name1),indexFor(name2));
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   132
    }
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   133
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   134
    /**
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   135
     * Dummy constructor.
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   136
     */
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   137
    protected Denotation() {
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   138
    }
44839fbb20db 8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff changeset
   139
}