hotspot/test/compiler/jsr292/NullConstantReceiver.java
author alanb
Sun, 19 Oct 2014 11:52:53 +0100
changeset 27178 885f4428b501
parent 26945 981df0f8be4e
child 40059 c2304140ed64
permissions -rw-r--r--
8060170: Support SIO_LOOPBACK_FAST_PATH option on Windows Reviewed-by: alanb Contributed-by: kirk.shoop@microsoft.com, v-valkop@microsoft.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26945
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
     1
/*
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
     4
 *
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
     8
 *
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    13
 * accompanied this code).
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    14
 *
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    18
 *
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    21
 * questions.
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    22
 */
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    23
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    24
/**
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    25
 * @test
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    26
 * @bug 8059556
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    27
 * @run main/othervm -Xbatch NullConstantReceiver
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    28
 */
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    29
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    30
import java.lang.invoke.MethodHandle;
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    31
import java.lang.invoke.MethodHandles;
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    32
import java.lang.invoke.MethodType;
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    33
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    34
public class NullConstantReceiver {
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    35
    static final MethodHandle target;
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    36
    static {
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    37
        try {
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    38
            target = MethodHandles.lookup().findVirtual(NullConstantReceiver.class, "test", MethodType.methodType(void.class));
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    39
        } catch (ReflectiveOperationException e) {
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    40
            throw new Error(e);
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    41
        }
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    42
    }
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    43
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    44
    public void test() {}
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    45
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    46
    static void run() throws Throwable {
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    47
        target.invokeExact((NullConstantReceiver) null);
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    48
    }
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    49
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    50
    public static void main(String[] args) throws Throwable {
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    51
        for (int i = 0; i<15000; i++) {
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    52
            try {
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    53
                run();
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    54
            } catch (NullPointerException e) {
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    55
                // expected
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    56
                continue;
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    57
            }
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    58
            throw new AssertionError("NPE wasn't thrown");
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    59
        }
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    60
        System.out.println("TEST PASSED");
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    61
    }
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    62
}