hotspot/test/runtime/invokedynamic/BootstrapMethodErrorTest.java
author psandoz
Fri, 14 Oct 2016 14:47:01 -0700
changeset 42074 c069e5e285cb
parent 30746 dfce1db72058
permissions -rw-r--r--
8166974: invokedynamic implementation should not wrap Errors Reviewed-by: dholmes, jrose
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30746
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
     1
/*
42074
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
30746
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
     4
 *
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
     7
 * published by the Free Software Foundation.
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
     8
 *
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    13
 * accompanied this code).
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    14
 *
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    18
 *
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    21
 * questions.
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    22
 */
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    23
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    24
/*
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    25
 * @test
42074
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    26
 * @bug 8051045 8166974
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    27
 * @summary Test exceptions from invokedynamic and the bootstrap method
30746
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    28
 * @modules java.base/jdk.internal.org.objectweb.asm
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    29
 * @run main BootstrapMethodErrorTest
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    30
 */
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    31
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    32
import jdk.internal.org.objectweb.asm.ClassWriter;
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    33
import jdk.internal.org.objectweb.asm.Handle;
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    34
import jdk.internal.org.objectweb.asm.MethodVisitor;
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    35
import jdk.internal.org.objectweb.asm.Opcodes;
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
    36
42074
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    37
import java.lang.invoke.CallSite;
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    38
import java.lang.invoke.ConstantCallSite;
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    39
import java.lang.invoke.MethodHandle;
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    40
import java.lang.invoke.MethodHandles;
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    41
import java.lang.invoke.MethodType;
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    42
import java.lang.invoke.WrongMethodTypeException;
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    43
import java.lang.reflect.InvocationTargetException;
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    44
import java.util.List;
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    45
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    46
public class BootstrapMethodErrorTest {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    47
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    48
    static abstract class IndyClassloader extends ClassLoader implements Opcodes {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    49
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    50
        public IndyClassloader() {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    51
            super(BootstrapMethodErrorTest.class.getClassLoader());
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    52
        }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    53
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    54
        @Override
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    55
        public Class findClass(String name) throws ClassNotFoundException {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    56
            byte[] b;
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    57
            try {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    58
                b = loadClassData(name);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    59
            }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    60
            catch (Throwable th) {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    61
                throw new ClassNotFoundException("Loading error", th);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    62
            }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    63
            return defineClass(name, b, 0, b.length);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    64
        }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    65
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    66
        static final String BOOTSTRAP_METHOD_CLASS_NAME = "C";
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    67
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    68
        static final String BOOTSTRAP_METHOD_NAME = "bsm";
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    69
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    70
        static final String INDY_CALLER_CLASS_NAME = "Exec";
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    71
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    72
        static final String BOOTSTRAP_METHOD_DESC = MethodType.methodType(
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    73
                Object.class, MethodHandles.Lookup.class, String.class, MethodType.class).
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    74
                toMethodDescriptorString();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    75
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    76
        private byte[] loadClassData(String name) throws Exception {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    77
            ClassWriter cw = new ClassWriter(
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    78
                    ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    79
            if (name.equals(BOOTSTRAP_METHOD_CLASS_NAME)) {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    80
                defineIndyBootstrapMethodClass(cw);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    81
                return cw.toByteArray();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    82
            }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    83
            else if (name.equals("Exec")) {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    84
                defineIndyCallingClass(cw);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    85
                return cw.toByteArray();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    86
            }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    87
            return null;
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    88
        }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    89
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    90
        void defineIndyCallingClass(ClassWriter cw) {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    91
            cw.visit(52, ACC_SUPER | ACC_PUBLIC, INDY_CALLER_CLASS_NAME, null, "java/lang/Object", null);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    92
            MethodVisitor mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "invoke", "()V", null, null);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    93
            mv.visitCode();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    94
            Handle h = new Handle(H_INVOKESTATIC,
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    95
                                  BOOTSTRAP_METHOD_CLASS_NAME, BOOTSTRAP_METHOD_NAME,
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    96
                                  BOOTSTRAP_METHOD_DESC, false);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    97
            mv.visitInvokeDynamicInsn(BOOTSTRAP_METHOD_CLASS_NAME, "()V", h);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    98
            mv.visitInsn(RETURN);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
    99
            mv.visitMaxs(0, 0);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   100
            mv.visitEnd();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   101
            cw.visitEnd();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   102
        }
30746
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
   103
42074
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   104
        void defineIndyBootstrapMethodClass(ClassWriter cw) {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   105
            cw.visit(52, ACC_SUPER | ACC_PUBLIC,
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   106
                     BOOTSTRAP_METHOD_CLASS_NAME, null, "java/lang/Object", null);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   107
            MethodVisitor mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC,
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   108
                                              BOOTSTRAP_METHOD_NAME, BOOTSTRAP_METHOD_DESC, null, null);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   109
            mv.visitCode();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   110
            defineIndyBootstrapMethodBody(mv);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   111
            mv.visitMaxs(0, 0);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   112
            mv.visitEnd();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   113
        }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   114
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   115
        void defineIndyBootstrapMethodBody(MethodVisitor mv) {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   116
            mv.visitInsn(ACONST_NULL);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   117
            mv.visitInsn(ARETURN);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   118
        }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   119
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   120
        void invoke() throws Exception {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   121
            Class.forName(BOOTSTRAP_METHOD_CLASS_NAME, true, this);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   122
            Class<?> exec = Class.forName(INDY_CALLER_CLASS_NAME, true, this);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   123
            exec.getMethod("invoke").invoke(null);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   124
        }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   125
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   126
        void test() throws Exception {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   127
            Class.forName(BOOTSTRAP_METHOD_CLASS_NAME, true, this);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   128
            Class<?> exec = Class.forName(INDY_CALLER_CLASS_NAME, true, this);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   129
            try {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   130
                exec.getMethod("invoke").invoke(null);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   131
                throw new RuntimeException("Expected InvocationTargetException but no exception at all was thrown");
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   132
            } catch (InvocationTargetException e) {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   133
                Throwable t = e.getCause();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   134
                for (Class<? extends Throwable> etc : expectedThrowableClasses()) {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   135
                    if (!etc.isInstance(t)) {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   136
                        throw new RuntimeException(
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   137
                                "Expected " + etc.getName() + " but got another exception: "
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   138
                                + t.getClass().getName(),
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   139
                                t);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   140
                    }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   141
                    t = t.getCause();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   142
                }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   143
            }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   144
        }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   145
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   146
        abstract List<Class<? extends Throwable>> expectedThrowableClasses();
30746
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
   147
    }
42074
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   148
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   149
    // Methods called by a bootstrap method
30746
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
   150
42074
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   151
    public static CallSite getCallSite() {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   152
        try {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   153
            MethodHandle mh = MethodHandles.lookup().findStatic(
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   154
                    BootstrapMethodErrorTest.class,
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   155
                    "target",
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   156
                    MethodType.methodType(Object.class, Object.class));
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   157
            return new ConstantCallSite(mh);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   158
        } catch (Exception e) {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   159
            throw new RuntimeException(e);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   160
        }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   161
    }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   162
    public static Object target(Object o) {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   163
        return null;
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   164
    }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   165
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   166
    static class TestThrowable extends Throwable {}
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   167
    public static void throwsTestThrowable() throws Throwable {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   168
        throw new TestThrowable();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   169
    }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   170
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   171
    static class TestError extends Error {}
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   172
    public static void throwsTestError() {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   173
        throw new TestError();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   174
    }
30746
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
   175
42074
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   176
    static class TestRuntimeException extends RuntimeException {}
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   177
    public static void throwsTestRuntimeException() {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   178
        throw new TestRuntimeException();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   179
    }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   180
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   181
    static class TestCheckedException extends Exception {}
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   182
    public static void throwsTestCheckedException() throws TestCheckedException {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   183
        throw new TestCheckedException();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   184
    }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   185
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   186
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   187
    // Test classes
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   188
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   189
    static class InaccessibleBootstrapMethod extends IndyClassloader {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   190
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   191
        void defineIndyBootstrapMethodClass(ClassWriter cw) {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   192
            cw.visit(52, ACC_SUPER | ACC_PUBLIC,
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   193
                     BOOTSTRAP_METHOD_CLASS_NAME, null, "java/lang/Object", null);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   194
            // Bootstrap method is declared to be private
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   195
            MethodVisitor mv = cw.visitMethod(ACC_PRIVATE | ACC_STATIC,
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   196
                                              BOOTSTRAP_METHOD_NAME, BOOTSTRAP_METHOD_DESC, null, null);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   197
            mv.visitCode();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   198
            defineIndyBootstrapMethodBody(mv);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   199
            mv.visitMaxs(0, 0);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   200
            mv.visitEnd();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   201
        }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   202
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   203
        @Override
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   204
        List<Class<? extends Throwable>> expectedThrowableClasses() {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   205
            return List.of(IllegalAccessError.class);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   206
        }
30746
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
   207
    }
42074
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   208
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   209
    static class BootstrapMethodDoesNotReturnCallSite extends IndyClassloader {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   210
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   211
        void defineIndyBootstrapMethodBody(MethodVisitor mv) {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   212
            // return null from the bootstrap method,
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   213
            // which cannot be cast to CallSite
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   214
            mv.visitInsn(ACONST_NULL);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   215
            mv.visitInsn(ARETURN);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   216
        }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   217
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   218
        @Override
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   219
        List<Class<? extends Throwable>> expectedThrowableClasses() {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   220
            return List.of(BootstrapMethodError.class, ClassCastException.class);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   221
        }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   222
    }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   223
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   224
    static class BootstrapMethodCallSiteHasWrongTarget extends IndyClassloader {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   225
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   226
        @Override
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   227
        void defineIndyBootstrapMethodBody(MethodVisitor mv) {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   228
            // Invoke the method BootstrapMethodErrorTest.getCallSite to obtain
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   229
            // a CallSite instance whose target is different from that of
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   230
            // the indy call site
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   231
            mv.visitMethodInsn(INVOKESTATIC, "BootstrapMethodErrorTest",
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   232
                               "getCallSite", "()Ljava/lang/invoke/CallSite;", false);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   233
            mv.visitInsn(ARETURN);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   234
        }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   235
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   236
        @Override
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   237
        List<Class<? extends Throwable>> expectedThrowableClasses() {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   238
            return List.of(BootstrapMethodError.class, WrongMethodTypeException.class);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   239
        }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   240
    }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   241
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   242
    abstract static class BootstrapMethodThrows extends IndyClassloader {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   243
        final String methodName;
30746
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
   244
42074
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   245
        public BootstrapMethodThrows(Class<? extends Throwable> t) {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   246
            this.methodName = "throws" + t.getSimpleName();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   247
        }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   248
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   249
        @Override
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   250
        void defineIndyBootstrapMethodBody(MethodVisitor mv) {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   251
            // Invoke the method whose name is methodName which will throw
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   252
            // an exception
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   253
            mv.visitMethodInsn(INVOKESTATIC, "BootstrapMethodErrorTest",
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   254
                               methodName, "()V", false);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   255
            mv.visitInsn(ACONST_NULL);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   256
            mv.visitInsn(ARETURN);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   257
        }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   258
    }
30746
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
   259
42074
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   260
    static class BootstrapMethodThrowsThrowable extends BootstrapMethodThrows {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   261
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   262
        public BootstrapMethodThrowsThrowable() {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   263
            super(TestThrowable.class);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   264
        }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   265
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   266
        @Override
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   267
        List<Class<? extends Throwable>> expectedThrowableClasses() {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   268
            return List.of(BootstrapMethodError.class, TestThrowable.class);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   269
        }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   270
    }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   271
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   272
    static class BootstrapMethodThrowsError extends BootstrapMethodThrows {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   273
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   274
        public BootstrapMethodThrowsError() {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   275
            super(TestError.class);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   276
        }
30746
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
   277
42074
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   278
        @Override
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   279
        List<Class<? extends Throwable>> expectedThrowableClasses() {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   280
            return List.of(TestError.class);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   281
        }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   282
    }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   283
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   284
    static class BootstrapMethodThrowsRuntimeException extends BootstrapMethodThrows {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   285
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   286
        public BootstrapMethodThrowsRuntimeException() {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   287
            super(TestRuntimeException.class);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   288
        }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   289
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   290
        @Override
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   291
        List<Class<? extends Throwable>> expectedThrowableClasses() {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   292
            return List.of(BootstrapMethodError.class, TestRuntimeException.class);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   293
        }
30746
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
   294
    }
42074
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   295
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   296
    static class BootstrapMethodThrowsCheckedException extends BootstrapMethodThrows {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   297
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   298
        public BootstrapMethodThrowsCheckedException() {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   299
            super(TestCheckedException.class);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   300
        }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   301
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   302
        @Override
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   303
        List<Class<? extends Throwable>> expectedThrowableClasses() {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   304
            return List.of(BootstrapMethodError.class, TestCheckedException.class);
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   305
        }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   306
    }
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   307
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   308
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   309
    public static void main(String[] args) throws Exception {
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   310
        new InaccessibleBootstrapMethod().test();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   311
        new BootstrapMethodDoesNotReturnCallSite().test();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   312
        new BootstrapMethodCallSiteHasWrongTarget().test();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   313
        new BootstrapMethodThrowsThrowable().test();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   314
        new BootstrapMethodThrowsError().test();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   315
        new BootstrapMethodThrowsRuntimeException().test();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   316
        new BootstrapMethodThrowsCheckedException().test();
c069e5e285cb 8166974: invokedynamic implementation should not wrap Errors
psandoz
parents: 30746
diff changeset
   317
    }
30746
dfce1db72058 8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
diff changeset
   318
}