Mercurial > hg > graal-compiler
annotate test/compiler/jsr292/NullConstantReceiver.java @ 20573:8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
Reviewed-by: kvn, jrose
author | vlivanov |
---|---|
date | Wed, 01 Oct 2014 12:34:45 -0700 |
parents | |
children |
rev | line source |
---|---|
20573
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
1 /* |
8ed0a8dbea70
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. |
8ed0a8dbea70
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. |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
4 * |
8ed0a8dbea70
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 |
8ed0a8dbea70
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 |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
8 * |
8ed0a8dbea70
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 |
8ed0a8dbea70
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 |
8ed0a8dbea70
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 |
8ed0a8dbea70
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 |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
13 * accompanied this code). |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
14 * |
8ed0a8dbea70
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 |
8ed0a8dbea70
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, |
8ed0a8dbea70
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. |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
18 * |
8ed0a8dbea70
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 |
8ed0a8dbea70
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 |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
21 * questions. |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
22 */ |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
23 |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
24 /** |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
25 * @test |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
26 * @bug 8059556 |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
27 * @run main/othervm -Xbatch NullConstantReceiver |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
28 */ |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
29 |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
30 import java.lang.invoke.MethodHandle; |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
31 import java.lang.invoke.MethodHandles; |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
32 import java.lang.invoke.MethodType; |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
33 |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
34 public class NullConstantReceiver { |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
35 static final MethodHandle target; |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
36 static { |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
37 try { |
8ed0a8dbea70
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)); |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
39 } catch (ReflectiveOperationException e) { |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
40 throw new Error(e); |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
41 } |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
42 } |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
43 |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
44 public void test() {} |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
45 |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
46 static void run() throws Throwable { |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
47 target.invokeExact((NullConstantReceiver) null); |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
48 } |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
49 |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
50 public static void main(String[] args) throws Throwable { |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
51 for (int i = 0; i<15000; i++) { |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
52 try { |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
53 run(); |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
54 } catch (NullPointerException e) { |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
55 // expected |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
56 continue; |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
57 } |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
58 throw new AssertionError("NPE wasn't thrown"); |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
59 } |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
60 System.out.println("TEST PASSED"); |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
61 } |
8ed0a8dbea70
8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
vlivanov
parents:
diff
changeset
|
62 } |