test/hotspot/jtreg/runtime/InvocationTests/invokeinterface/Generator.java
author hseigel
Wed, 26 Jun 2019 09:06:32 -0400
changeset 55497 d3a33953b936
permissions -rw-r--r--
8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo Summary: Add JTReg compatible main programs to run tests for various invoke* instructions Reviewed-by: lfoltan, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
55497
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
     1
/*
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
     2
 * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
     4
 *
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
     8
 *
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    13
 * accompanied this code).
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    14
 *
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    18
 *
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    21
 * questions.
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    22
 *
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    23
 */
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    24
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    25
/*
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    26
 * INVOKE_INTERFACE EXPECTED RESULTS
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    27
 *
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    28
 * Let C be the class of objectref. The actual method to be invoked is selected
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    29
 * by the following lookup procedure:
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    30
 *     - If C contains a declaration for an instance method with the same name
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    31
 *     and descriptor as the resolved method, then this is the method to be
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    32
 *     invoked, and the lookup procedure terminates.
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    33
 *
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    34
 *     - Otherwise, if C has a superclass, this same lookup procedure is
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    35
 *     performed recursively using the direct superclass of C; the method to be
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    36
 *     invoked is the result of the recursive invocation of this lookup
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    37
 *     procedure.
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    38
 *
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    39
 * Otherwise, if the class of objectref does not implement the resolved
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    40
 * interface, invokeinterface throws an IncompatibleClassChangeError?.
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    41
 *
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    42
 * Otherwise, if no method matching the resolved name and descriptor is
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    43
 * selected, invokeinterface throws an AbstractMethodError?.
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    44
 *
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    45
 * Otherwise, if the selected method is not public, invokeinterface throws an
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    46
 * IllegalAccessError. Note that it cannot be private because private methods
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    47
 * are ignored when searching for an interface method.
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    48
 *
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    49
 * My translation:
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    50
 *      1. Resolve compile-time class/method.
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    51
 *      2. Look up runtime class C, if it contains a name/signature match,
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    52
 *      and it is not private, invoke it.
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    53
 *      3. If it does not, recursively lookup direct superclass of C.
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    54
 *      4. If selected method is not public, throw IllegalAccessError
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    55
 *
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    56
 * InvokeInterface Results:
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    57
 *    - A interface class, declares A.m
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    58
 *    - A compile-time resolved class
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    59
 *    - C runtime resolved class
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    60
 *    - InvokeInterface will ALWAYS invoke C.m if C.m exists and is not private,
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    61
 *    regardless of overriding or accessibility
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    62
 *    - InvokeInterface will invoke a non-private B.m if C.m does not exist,
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    63
 *    regardless of overriding or accessibility
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    64
 *
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    65
 * Note: assuming Interface is public
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    66
 *
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    67
 * TODO: member interfaces can be protected and private and have special hiding
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    68
 * rules (JLS 8.5)
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    69
 */
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    70
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    71
package invokeinterface;
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    72
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    73
import static jdk.internal.org.objectweb.asm.Opcodes.*;
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    74
import shared.AbstractGenerator;
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    75
import shared.AccessType;
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    76
import shared.Utils;
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    77
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    78
import java.util.HashMap;
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    79
import java.util.Map;
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    80
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    81
public class Generator extends AbstractGenerator {
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    82
    public Generator(String[] args) {
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    83
        super(args);
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    84
    }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    85
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    86
    protected Checker getChecker(Class paramClass, Class targetClass) {
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    87
        return new Checker(paramClass, targetClass);
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    88
    }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    89
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    90
    public static void main (String[] args) throws Exception {
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    91
        new Generator(args).run();
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    92
    }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    93
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    94
    private void run() throws Exception {
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    95
        // Specify package names
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    96
        String pkg1 = "a.";
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    97
        String pkg2 = "b.";
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    98
        String pkg3 = "c.";
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
    99
        String pkgIntf = "i.";
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   100
        String[] packages = new String[] { "", pkg1, pkg2, pkg3, pkgIntf };
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   101
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   102
        int testNum = 0;
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   103
        boolean isPassed = true;
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   104
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   105
        // Hierarchy
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   106
        // The following triples will be used during further
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   107
        // hierarchy construction and will specify packages for A, B and C
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   108
        String[][] packageSets = new String[][] {
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   109
              {   "",   "",   "", ""}
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   110
            , {   "",   "",   "", pkgIntf }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   111
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   112
            , {   "", pkg1, pkg1, "" }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   113
            , {   "", pkg1, pkg1, pkg1 }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   114
            , {   "", pkg1, pkg1, pkgIntf }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   115
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   116
            , {   "", pkg1, pkg2, "" }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   117
            , {   "", pkg1, pkg2, pkg1}
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   118
            , {   "", pkg1, pkg2, pkg2}
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   119
            , {   "", pkg1, pkg2, pkgIntf}
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   120
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   121
            , { pkg1, pkg1, pkg1, pkg1 }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   122
            , { pkg1, pkg1, pkg1, pkgIntf }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   123
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   124
            , { pkg1, pkg1, pkg2, pkg1 }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   125
            , { pkg1, pkg1, pkg2, pkg2 }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   126
            , { pkg1, pkg1, pkg2, pkgIntf }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   127
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   128
            , { pkg1, pkg2, pkg1, pkg1 }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   129
            , { pkg1, pkg2, pkg1, pkg2 }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   130
            , { pkg1, pkg2, pkg1, pkgIntf }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   131
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   132
            , { pkg1, pkg2, pkg2, pkg1 }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   133
            , { pkg1, pkg2, pkg2, pkg2 }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   134
            , { pkg1, pkg2, pkg2, pkgIntf }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   135
        };
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   136
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   137
        String [] header = new String[] {
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   138
            String.format("%30s %68s %25s", "Method access modifiers", "Call site location", "Status")
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   139
                , String.format("%5s  %-12s %-12s %-12s %-12s   %7s %7s %7s %7s %7s %7s %7s"
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   140
                        , "  # "
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   141
                        , "A.m()"
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   142
                        , "B.m()"
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   143
                        , "C.m()"
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   144
                        , "I.m()"
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   145
                        , "  C  "
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   146
                        , "pkgC "
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   147
                        , "  B  "
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   148
                        , " pkgB"
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   149
                        , "  A  "
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   150
                        , "pkgA"
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   151
                        , "Intf"
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   152
                        )
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   153
                , "--------------------------------------------------------------------------------------------------------------------"
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   154
        };
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   155
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   156
        for (String aHeader : header) {
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   157
            System.out.println(aHeader);
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   158
        }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   159
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   160
        for (String[] pkgSet : packageSets) {
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   161
            String packageA = pkgSet[0];
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   162
            String packageB = pkgSet[1];
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   163
            String packageC = pkgSet[2];
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   164
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   165
            String packageIntf = pkgSet[3];
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   166
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   167
            String classNameA = packageA + "A";
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   168
            String classNameB = packageB + "B";
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   169
            String classNameC = packageC + "C";
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   170
            String classNameIntf = packageIntf + "I";
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   171
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   172
            // For all possible access modifier combinations
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   173
            for (AccessType accessA : AccessType.values()) {
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   174
                for (AccessType accessB : AccessType.values()) {
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   175
                    for (AccessType accessC : AccessType.values()) {
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   176
                        for (AccessType accessIntf : AccessType.values()) {
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   177
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   178
                            if (accessIntf == AccessType.UNDEF) {
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   179
                                continue;
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   180
                            }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   181
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   182
                            for (int I = 0; I < 4; I++) {
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   183
                                boolean isAbstractA = ((I & 1) != 0);
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   184
                                boolean isAbstractB = ((I & 2) != 0);
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   185
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   186
                                testNum++;
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   187
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   188
                                Map<String, byte[]> classes = new HashMap<String, byte[]>();
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   189
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   190
                                // TODO: add non-PUBLIC interfaces, then particular call sites will affect the results
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   191
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   192
                                // Generate interface Intf
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   193
                                classes.put(
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   194
                                        classNameIntf
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   195
                                        , new ClassGenerator( classNameIntf
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   196
                                                            , "java.lang.Object"
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   197
                                                            , ACC_ABSTRACT | ACC_INTERFACE | accessIntf.value())
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   198
                                            .addTargetMethod(AccessType.PUBLIC)
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   199
                                            .getClassFile()
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   200
                                        );
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   201
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   202
                                // Generate class A
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   203
                                classes.put(
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   204
                                        classNameA
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   205
                                        , new ClassGenerator( classNameA
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   206
                                                            , "java.lang.Object"
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   207
                                                            , ACC_PUBLIC | ( isAbstractA ? ACC_ABSTRACT : 0))
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   208
                                            .addTargetMethod(accessA)
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   209
                                            .addCaller(classNameIntf)
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   210
                                            .getClassFile()
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   211
                                        );
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   212
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   213
                                // Generate class B
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   214
                                classes.put(
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   215
                                        classNameB
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   216
                                        , new ClassGenerator( classNameB
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   217
                                                            , classNameA
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   218
                                                            , ACC_PUBLIC | ( isAbstractB ? ACC_ABSTRACT : 0)
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   219
                                                            , new String[] { Utils.getInternalName(classNameIntf) })
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   220
                                            .addTargetMethod(accessB)
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   221
                                            .addCaller(classNameIntf)
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   222
                                            .getClassFile()
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   223
                                        );
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   224
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   225
                                // Generate class C
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   226
                                classes.put( classNameC
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   227
                                           , new ClassGenerator( classNameC, classNameB )
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   228
                                               .addTargetMethod(accessC)
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   229
                                               .addCaller(classNameIntf)
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   230
                                               .getClassFile()
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   231
                                           );
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   232
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   233
                                // Generate package callers
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   234
                                for (String pkg : packages) {
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   235
                                    classes.put( pkg+"Caller"
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   236
                                               , new ClassGenerator(pkg+"Caller")
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   237
                                                   .addCaller(classNameIntf)
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   238
                                                   .getClassFile()
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   239
                                               );
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   240
                                }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   241
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   242
                                String caseDescription =
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   243
                                        String.format("%-12s %-12s %-12s %-12s| "
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   244
                                            , (isAbstractA ? "! " : "  ") + classNameA + " " + accessA
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   245
                                            , (isAbstractB ? "! " : "  ") + classNameB + " " + accessB
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   246
                                            , classNameC + " " + accessC
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   247
                                            , accessIntf + " " + classNameIntf
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   248
                                            );
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   249
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   250
                                String[] callSites = new String[] {
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   251
                                        classNameC
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   252
                                        , packageC+"Caller"
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   253
                                        , classNameB
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   254
                                        , packageB+"Caller"
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   255
                                        , classNameA
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   256
                                        , packageA+"Caller"
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   257
                                        , packageIntf+"Caller"
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   258
                                };
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   259
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   260
                                boolean result = exec(classes, caseDescription, classNameIntf, classNameC, callSites);
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   261
                                isPassed = isPassed && result;
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   262
                            }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   263
                        }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   264
                    }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   265
                }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   266
            }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   267
        }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   268
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   269
        // Print footer
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   270
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   271
        for (int i = header.length-1; i >= 0; i--) {
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   272
            System.out.println(header[i]);
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   273
        }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   274
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   275
        if (executeTests) {
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   276
            System.out.printf("\nEXECUTION STATUS: %s\n", (isPassed? "PASSED" : "FAILED"));
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   277
        }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   278
    }
d3a33953b936 8224137: Analyze and port invocation tests to jtreg and co-locate to jdk repo
hseigel
parents:
diff changeset
   279
}