langtools/test/tools/javac/meth/TestCP.java
author psandoz
Mon, 23 May 2016 12:48:18 +0200
changeset 38537 ba5503adca64
parent 30846 2b3f379840f0
permissions -rw-r--r--
8149821: Add VarHandle signature-polymorphic invocation byte code tests Reviewed-by: mcimadamore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6934
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
     1
/*
38537
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
     2
 * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
6934
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
     4
 *
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
     7
 * published by the Free Software Foundation.
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
     8
 *
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    13
 * accompanied this code).
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    14
 *
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    18
 *
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    21
 * questions.
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    22
 */
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    23
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    24
/*
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    25
 * @test
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    26
 * @bug 6991980
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    27
 * @summary  polymorphic signature calls don't share the same CP entries
30846
2b3f379840f0 8074432: Move jdeps and javap to jdk.jdeps module
mchung
parents: 30730
diff changeset
    28
 * @modules jdk.jdeps/com.sun.tools.classfile
6934
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    29
 * @run main TestCP
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    30
 */
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    31
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    32
import com.sun.tools.classfile.Instruction;
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    33
import com.sun.tools.classfile.Attribute;
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    34
import com.sun.tools.classfile.ClassFile;
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    35
import com.sun.tools.classfile.Code_attribute;
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    36
import com.sun.tools.classfile.ConstantPool.*;
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    37
import com.sun.tools.classfile.Method;
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    38
9082
53409a3a93f8 7028405: (javac) remove unused JSR-292 code
ksrini
parents: 8036
diff changeset
    39
import java.lang.invoke.*;
6934
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    40
import java.io.*;
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    41
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    42
public class TestCP {
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    43
38537
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    44
    static class TestMethodHandleInvokeExact {
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    45
        static final String PS_TYPE = "(Ljava/lang/String;IC)Ljava/lang/Number;";
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    46
6934
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    47
        void test(MethodHandle mh) throws Throwable {
8036
17b976649c61 6992698: JSR 292: remove support for transient syntax in polymorphic signature calls
mcimadamore
parents: 6934
diff changeset
    48
            Number n = (Number)mh.invokeExact("daddy",1,'n');
6934
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    49
            n = (Number)mh.invokeExact("bunny",1,'d');
8036
17b976649c61 6992698: JSR 292: remove support for transient syntax in polymorphic signature calls
mcimadamore
parents: 6934
diff changeset
    50
            n = (Number)(mh.invokeExact("foo",1,'d'));
17b976649c61 6992698: JSR 292: remove support for transient syntax in polymorphic signature calls
mcimadamore
parents: 6934
diff changeset
    51
            n = (Number)((mh.invokeExact("bar",1,'d')));
6934
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    52
        }
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    53
    }
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    54
38537
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    55
    static class TestVarHandleGet {
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    56
        static final String PS_TYPE = "(Ljava/lang/String;IC)Ljava/lang/Number;";
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    57
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    58
        // Test with sig-poly return type
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    59
        void test(VarHandle vh) throws Throwable {
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    60
            Number n = (Number)vh.get("daddy",1,'n');
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    61
            n = (Number)vh.get("bunny",1,'d');
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    62
            n = (Number)(vh.get("foo",1,'d'));
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    63
            n = (Number)((vh.get("bar",1,'d')));
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    64
        }
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    65
    }
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    66
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    67
    static class TestVarHandleSet {
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    68
        static final String PS_TYPE = "(Ljava/lang/String;IC)V";
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    69
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    70
        // Test with non-sig-poly void return type
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    71
        void test(VarHandle vh) throws Throwable {
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    72
            vh.set("daddy",1,'n');
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    73
            vh.set("bunny",1,'d');
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    74
            vh.set("foo",1,'d');
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    75
            vh.set("bar",1,'d');
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    76
        }
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    77
    }
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    78
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    79
    static class TestVarHandleCompareAndSet {
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    80
        static final String PS_TYPE = "(Ljava/lang/String;IC)Z";
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    81
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    82
        // Test with non-sig-poly boolean return type
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    83
        void test(VarHandle vh) throws Throwable {
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    84
            boolean r = vh.compareAndSet("daddy",1,'n');
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    85
            r = vh.compareAndSet("bunny",1,'d');
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    86
            r = (vh.compareAndSet("foo",1,'d'));
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    87
            r = ((vh.compareAndSet("bar",1,'d')));
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    88
        }
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    89
    }
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    90
8036
17b976649c61 6992698: JSR 292: remove support for transient syntax in polymorphic signature calls
mcimadamore
parents: 6934
diff changeset
    91
    static final int PS_CALLS_COUNT = 4;
6934
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    92
    static final String TEST_METHOD_NAME = "test";
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    93
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    94
    public static void main(String... args) throws Exception {
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    95
        new TestCP().run();
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    96
    }
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    97
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
    98
    public void run() throws Exception {
38537
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
    99
        verifySigPolyInvokeVirtual(
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   100
                getTestFile(TestMethodHandleInvokeExact.class),
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   101
                TestMethodHandleInvokeExact.PS_TYPE);
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   102
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   103
        verifySigPolyInvokeVirtual(
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   104
                getTestFile(TestVarHandleGet.class),
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   105
                TestVarHandleGet.PS_TYPE);
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   106
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   107
        verifySigPolyInvokeVirtual(
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   108
                getTestFile(TestVarHandleSet.class),
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   109
                TestVarHandleSet.PS_TYPE);
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   110
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   111
        verifySigPolyInvokeVirtual(
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   112
                getTestFile(TestVarHandleCompareAndSet.class),
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   113
                TestVarHandleCompareAndSet.PS_TYPE);
6934
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   114
    }
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   115
38537
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   116
    static File getTestFile(Class<?> c) {
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   117
        String workDir = System.getProperty("test.classes");
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   118
        return new File(workDir, getTestName(c));
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   119
    }
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   120
    static String getTestName(Class<?> c) {
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   121
        return c.getName() + ".class";
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   122
    }
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   123
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   124
    void verifySigPolyInvokeVirtual(File f, String psType) {
6934
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   125
        System.err.println("verify: " + f);
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   126
        try {
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   127
            int count = 0;
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   128
            ClassFile cf = ClassFile.read(f);
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   129
            Method testMethod = null;
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   130
            for (Method m : cf.methods) {
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   131
                if (m.getName(cf.constant_pool).equals(TEST_METHOD_NAME)) {
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   132
                    testMethod = m;
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   133
                    break;
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   134
                }
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   135
            }
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   136
            if (testMethod == null) {
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   137
                throw new Error("Test method not found");
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   138
            }
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   139
            Code_attribute ea = (Code_attribute)testMethod.attributes.get(Attribute.Code);
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   140
            if (testMethod == null) {
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   141
                throw new Error("Code attribute for test() method not found");
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   142
            }
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   143
            int instr_count = 0;
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   144
            int cp_entry = -1;
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   145
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   146
            for (Instruction i : ea.getInstructions()) {
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   147
                if (i.getMnemonic().equals("invokevirtual")) {
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   148
                    instr_count++;
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   149
                    if (cp_entry == -1) {
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   150
                        cp_entry = i.getUnsignedShort(1);
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   151
                    } else if (cp_entry != i.getUnsignedShort(1)) {
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   152
                        throw new Error("Unexpected CP entry in polymorphic signature call");
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   153
                    }
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   154
                    CONSTANT_Methodref_info methRef =
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   155
                            (CONSTANT_Methodref_info)cf.constant_pool.get(cp_entry);
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   156
                    String type = methRef.getNameAndTypeInfo().getType();
38537
ba5503adca64 8149821: Add VarHandle signature-polymorphic invocation byte code tests
psandoz
parents: 30846
diff changeset
   157
                    if (!type.equals(psType)) {
6934
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   158
                        throw new Error("Unexpected type in polymorphic signature call: " + type);
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   159
                    }
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   160
                }
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   161
            }
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   162
            if (instr_count != PS_CALLS_COUNT) {
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   163
                throw new Error("Wrong number of polymorphic signature call found: " + instr_count);
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   164
            }
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   165
        } catch (Exception e) {
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   166
            e.printStackTrace();
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   167
            throw new Error("error reading " + f +": " + e);
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   168
        }
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   169
    }
258e5f06880f 6991980: polymorphic signature calls don't share the same CP entries
mcimadamore
parents:
diff changeset
   170
}