test/hotspot/jtreg/runtime/ConstantPool/IntfMethod.java
author iignatyev
Thu, 02 Aug 2018 14:40:55 -0700
changeset 51287 7b1ddbafa134
parent 47216 71c04702a3d5
permissions -rw-r--r--
8208655: use JTreg skipped status in hotspot tests Reviewed-by: kvn, hseigel, iklam
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38719
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
     1
/*
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
     4
 *
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
     7
 * published by the Free Software Foundation.
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
     8
 *
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    13
 * accompanied this code).
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    14
 *
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    18
 *
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    21
 * questions.
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    22
 */
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    23
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    24
/*
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    25
 * @test
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    26
 * $bug 8087223
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    27
 * @summary Adding constantTag to keep method call consistent with it.
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    28
 * @modules java.base/jdk.internal.org.objectweb.asm
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    29
 *          java.base/jdk.internal.misc
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    30
 *          java.management
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    31
 * @compile -XDignore.symbol.file IntfMethod.java
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    32
 * @run main/othervm IntfMethod
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    33
 * @run main/othervm -Xint IntfMethod
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    34
 * @run main/othervm -Xcomp IntfMethod
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    35
 */
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    36
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    37
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    38
import jdk.internal.org.objectweb.asm.*;
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    39
import java.io.FileOutputStream;
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    40
import java.lang.reflect.InvocationTargetException;
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    41
import static jdk.internal.org.objectweb.asm.Opcodes.*;
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    42
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    43
public class IntfMethod {
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    44
    static byte[] dumpC() {
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    45
        ClassWriter cw = new ClassWriter(0);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    46
        cw.visit(52, ACC_PUBLIC | ACC_SUPER, "C", null, "java/lang/Object", new String[]{"I"});
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    47
        {
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    48
            MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    49
            mv.visitCode();
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    50
            mv.visitVarInsn(ALOAD, 0);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    51
            mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    52
            mv.visitInsn(RETURN);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    53
            mv.visitMaxs(1, 1);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    54
            mv.visitEnd();
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    55
        }
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    56
        {
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    57
            MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "testSpecialIntf", "()V", null, null);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    58
            mv.visitCode();
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    59
            mv.visitVarInsn(ALOAD, 0);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    60
            mv.visitMethodInsn(INVOKESPECIAL, "I", "f1", "()V", /*itf=*/false);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    61
            mv.visitInsn(RETURN);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    62
            mv.visitMaxs(1, 1);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    63
            mv.visitEnd();
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    64
        }
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    65
        {
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    66
            MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "testStaticIntf", "()V", null, null);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    67
            mv.visitCode();
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    68
            mv.visitMethodInsn(INVOKESTATIC, "I", "f2", "()V", /*itf=*/false);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    69
            mv.visitInsn(RETURN);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    70
            mv.visitMaxs(1, 1);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    71
            mv.visitEnd();
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    72
        }
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    73
        {
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    74
            MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "testSpecialClass", "()V", null, null);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    75
            mv.visitCode();
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    76
            mv.visitVarInsn(ALOAD, 0);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    77
            mv.visitMethodInsn(INVOKESPECIAL, "C", "f1", "()V", /*itf=*/true);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    78
            mv.visitInsn(RETURN);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    79
            mv.visitMaxs(1, 1);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    80
            mv.visitEnd();
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    81
        }
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    82
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    83
        {
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    84
            MethodVisitor mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "f2", "()V", null, null);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    85
            mv.visitCode();
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    86
            mv.visitInsn(RETURN);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    87
            mv.visitMaxs(0, 1);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    88
            mv.visitEnd();
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    89
        }
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    90
        {
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    91
            MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "testStaticClass", "()V", null, null);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    92
            mv.visitCode();
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    93
            mv.visitMethodInsn(INVOKESTATIC, "C", "f2", "()V", /*itf=*/true);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    94
            mv.visitInsn(RETURN);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    95
            mv.visitMaxs(1, 1);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    96
            mv.visitEnd();
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    97
        }
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    98
        cw.visitEnd();
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
    99
        return cw.toByteArray();
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   100
    }
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   101
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   102
    static byte[] dumpI() {
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   103
        ClassWriter cw = new ClassWriter(0);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   104
        cw.visit(52, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, "I", null, "java/lang/Object", null);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   105
        {
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   106
            MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "f1", "()V", null, null);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   107
            mv.visitCode();
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   108
            mv.visitInsn(RETURN);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   109
            mv.visitMaxs(0, 1);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   110
            mv.visitEnd();
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   111
        }
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   112
        {
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   113
            MethodVisitor mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "f2", "()V", null, null);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   114
            mv.visitCode();
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   115
            mv.visitInsn(RETURN);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   116
            mv.visitMaxs(0, 1);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   117
            mv.visitEnd();
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   118
        }
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   119
        cw.visitEnd();
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   120
        return cw.toByteArray();
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   121
    }
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   122
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   123
    static class CL extends ClassLoader {
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   124
        @Override
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   125
        protected Class<?> findClass(String name) throws ClassNotFoundException {
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   126
            byte[] classFile;
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   127
            switch (name) {
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   128
                case "I": classFile = dumpI(); break;
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   129
                case "C": classFile = dumpC(); break;
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   130
                default:
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   131
                    throw new ClassNotFoundException(name);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   132
            }
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   133
            return defineClass(name, classFile, 0, classFile.length);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   134
        }
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   135
    }
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   136
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   137
    public static void main(String[] args) throws Throwable {
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   138
        Class<?> cls = (new CL()).loadClass("C");
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   139
        try (FileOutputStream fos = new FileOutputStream("I.class")) { fos.write(dumpI()); }
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   140
        try (FileOutputStream fos = new FileOutputStream("C.class")) { fos.write(dumpC()); }
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   141
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   142
        int success = 0;
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   143
        for (String name : new String[] { "testSpecialIntf", "testStaticIntf", "testSpecialClass", "testStaticClass"}) {
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   144
            System.out.printf("%s: ", name);
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   145
            try {
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   146
                cls.getMethod(name).invoke(cls.newInstance());
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   147
                System.out.println("FAILED - ICCE not thrown");
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   148
            } catch (Throwable e) {
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   149
                if (e instanceof InvocationTargetException &&
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   150
                    e.getCause() != null && e.getCause() instanceof IncompatibleClassChangeError) {
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   151
                    System.out.println("PASSED - expected ICCE thrown");
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   152
                    success++;
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   153
                    continue;
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   154
                }
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   155
            }
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   156
        }
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   157
        if (success != 4) throw new Exception("Failed to catch ICCE");
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   158
    }
133bf85c3f36 8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
diff changeset
   159
}