8059556: C2: crash while inlining MethodHandle invocation w/ null receiver

Wed, 01 Oct 2014 12:34:45 -0700

author
vlivanov
date
Wed, 01 Oct 2014 12:34:45 -0700
changeset 7287
8ed0a8dbea70
parent 7286
87f199a9c1b1
child 7288
9dc314de223d

8059556: C2: crash while inlining MethodHandle invocation w/ null receiver
Reviewed-by: kvn, jrose

src/share/vm/opto/callGenerator.cpp file | annotate | diff | comparison | revisions
test/compiler/jsr292/NullConstantReceiver.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/opto/callGenerator.cpp	Mon Sep 29 11:46:05 2014 -0700
     1.2 +++ b/src/share/vm/opto/callGenerator.cpp	Wed Oct 01 12:34:45 2014 -0700
     1.3 @@ -862,7 +862,7 @@
     1.4                                              call_does_dispatch, vtable_index);  // out-parameters
     1.5            // We lack profiling at this call but type speculation may
     1.6            // provide us with a type
     1.7 -          speculative_receiver_type = receiver_type->speculative_type();
     1.8 +          speculative_receiver_type = (receiver_type != NULL) ? receiver_type->speculative_type() : NULL;
     1.9          }
    1.10  
    1.11          CallGenerator* cg = C->call_generator(target, vtable_index, call_does_dispatch, jvms, true, PROB_ALWAYS, speculative_receiver_type, true, true);
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/compiler/jsr292/NullConstantReceiver.java	Wed Oct 01 12:34:45 2014 -0700
     2.3 @@ -0,0 +1,62 @@
     2.4 +/*
     2.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
     2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 + *
     2.8 + * This code is free software; you can redistribute it and/or modify it
     2.9 + * under the terms of the GNU General Public License version 2 only, as
    2.10 + * published by the Free Software Foundation.
    2.11 + *
    2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.15 + * version 2 for more details (a copy is included in the LICENSE file that
    2.16 + * accompanied this code).
    2.17 + *
    2.18 + * You should have received a copy of the GNU General Public License version
    2.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.21 + *
    2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    2.23 + * or visit www.oracle.com if you need additional information or have any
    2.24 + * questions.
    2.25 + */
    2.26 +
    2.27 +/**
    2.28 + * @test
    2.29 + * @bug 8059556
    2.30 + * @run main/othervm -Xbatch NullConstantReceiver
    2.31 + */
    2.32 +
    2.33 +import java.lang.invoke.MethodHandle;
    2.34 +import java.lang.invoke.MethodHandles;
    2.35 +import java.lang.invoke.MethodType;
    2.36 +
    2.37 +public class NullConstantReceiver {
    2.38 +    static final MethodHandle target;
    2.39 +    static {
    2.40 +        try {
    2.41 +            target = MethodHandles.lookup().findVirtual(NullConstantReceiver.class, "test", MethodType.methodType(void.class));
    2.42 +        } catch (ReflectiveOperationException e) {
    2.43 +            throw new Error(e);
    2.44 +        }
    2.45 +    }
    2.46 +
    2.47 +    public void test() {}
    2.48 +
    2.49 +    static void run() throws Throwable {
    2.50 +        target.invokeExact((NullConstantReceiver) null);
    2.51 +    }
    2.52 +
    2.53 +    public static void main(String[] args) throws Throwable {
    2.54 +        for (int i = 0; i<15000; i++) {
    2.55 +            try {
    2.56 +                run();
    2.57 +            } catch (NullPointerException e) {
    2.58 +                // expected
    2.59 +                continue;
    2.60 +            }
    2.61 +            throw new AssertionError("NPE wasn't thrown");
    2.62 +        }
    2.63 +        System.out.println("TEST PASSED");
    2.64 +    }
    2.65 +}

mercurial