test/hotspot/jtreg/compiler/jsr292/NullConstantReceiver.java
author prr
Thu, 26 Jul 2018 10:00:40 -0700
changeset 51251 0a7a0a6dfa22
parent 47216 71c04702a3d5
permissions -rw-r--r--
Merge
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
41319
af9a986a9ce2 8164508: unexpected profiling mismatch in c1 generated code
jcm
parents: 40882
diff changeset
    26
 * @bug 8059556 8158639 8164508
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 26945
diff changeset
    27
 *
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 26945
diff changeset
    28
 * @run main/othervm -Xbatch compiler.jsr292.NullConstantReceiver
40882
23f882a600ce 8158639: C2 compilation fails with SIGSEGV
jcm
parents: 40059
diff changeset
    29
 * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::run compiler.jsr292.NullConstantReceiver
41319
af9a986a9ce2 8164508: unexpected profiling mismatch in c1 generated code
jcm
parents: 40882
diff changeset
    30
 * @run main/othervm -Xbatch -XX:CompileCommand=compileonly,*::run compiler.jsr292.NullConstantReceiver
26945
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    31
 */
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    32
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 26945
diff changeset
    33
package compiler.jsr292;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 26945
diff changeset
    34
26945
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    35
import java.lang.invoke.MethodHandle;
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    36
import java.lang.invoke.MethodHandles;
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    37
import java.lang.invoke.MethodType;
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    38
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    39
public class NullConstantReceiver {
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    40
    static final MethodHandle target;
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    41
    static {
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    42
        try {
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    43
            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
    44
        } catch (ReflectiveOperationException e) {
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    45
            throw new Error(e);
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    46
        }
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    47
    }
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
    public void test() {}
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    50
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    51
    static void run() throws Throwable {
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    52
        target.invokeExact((NullConstantReceiver) null);
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    53
    }
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    54
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    55
    public static void main(String[] args) throws Throwable {
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    56
        for (int i = 0; i<15000; i++) {
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    57
            try {
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    58
                run();
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    59
            } catch (NullPointerException e) {
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    60
                // expected
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    61
                continue;
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    62
            }
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    63
            throw new AssertionError("NPE wasn't thrown");
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    64
        }
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    65
        System.out.println("TEST PASSED");
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    66
    }
981df0f8be4e 8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff changeset
    67
}