test/runtime/lambda-features/InvokespecialInterface.java

Fri, 07 Feb 2014 18:30:27 -0500

author
coleenp
date
Fri, 07 Feb 2014 18:30:27 -0500
changeset 6307
10c9507f544a
parent 6306
76a75ac07a92
child 6876
710a3c8b516e
child 7290
90257dfad6e3
permissions
-rw-r--r--

8033528: assert(0 <= i && i < length()) failed: index out of bounds
Summary: Restoring bytecodes for invokedynamic had wrong index calculation added testing stress option.
Reviewed-by: twisti, hseigel

coleenp@6306 1 /*
coleenp@6306 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
coleenp@6306 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
coleenp@6306 4 *
coleenp@6306 5 * This code is free software; you can redistribute it and/or modify it
coleenp@6306 6 * under the terms of the GNU General Public License version 2 only, as
coleenp@6306 7 * published by the Free Software Foundation.
coleenp@6306 8 *
coleenp@6306 9 * This code is distributed in the hope that it will be useful, but WITHOUT
coleenp@6306 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
coleenp@6306 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
coleenp@6306 12 * version 2 for more details (a copy is included in the LICENSE file that
coleenp@6306 13 * accompanied this code).
coleenp@6306 14 *
coleenp@6306 15 * You should have received a copy of the GNU General Public License version
coleenp@6306 16 * 2 along with this work; if not, write to the Free Software Foundation,
coleenp@6306 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
coleenp@6306 18 *
coleenp@6306 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
coleenp@6306 20 * or visit www.oracle.com if you need additional information or have any
coleenp@6306 21 * questions.
coleenp@6306 22 *
coleenp@6306 23 */
coleenp@6306 24
coleenp@6306 25 /*
coleenp@6306 26 * @test
coleenp@6306 27 * @bug 8032024
coleenp@6306 28 * @bug 8025937
coleenp@6307 29 * @bug 8033528
coleenp@6306 30 * @summary [JDK 8] Test invokespecial and invokeinterface with the same JVM_CONSTANT_InterfaceMethodref
coleenp@6307 31 * @run main/othervm -XX:+StressRewriter InvokespecialInterface
coleenp@6306 32 */
coleenp@6306 33 import java.util.function.*;
coleenp@6306 34 import java.util.*;
coleenp@6306 35
coleenp@6306 36 interface I {
coleenp@6306 37 default void imethod() { System.out.println("I::imethod"); }
coleenp@6306 38 }
coleenp@6306 39
coleenp@6306 40 class C implements I {
coleenp@6306 41 public void foo() { I.super.imethod(); } // invokespecial InterfaceMethod
coleenp@6306 42 public void bar() { I i = this; i.imethod(); } // invokeinterface same
coleenp@6306 43 public void doSomeInvokedynamic() {
coleenp@6306 44 String str = "world";
coleenp@6306 45 Supplier<String> foo = ()->"hello, "+str;
coleenp@6306 46 String res = foo.get();
coleenp@6306 47 System.out.println(res);
coleenp@6306 48 }
coleenp@6306 49 }
coleenp@6306 50
coleenp@6306 51 public class InvokespecialInterface {
coleenp@6306 52 public static void main(java.lang.String[] unused) {
coleenp@6306 53 // need to create C and call I::foo()
coleenp@6306 54 C c = new C();
coleenp@6306 55 c.foo();
coleenp@6306 56 c.bar();
coleenp@6306 57 c.doSomeInvokedynamic();
coleenp@6306 58 }
coleenp@6306 59 };
coleenp@6306 60
coleenp@6306 61

mercurial