jdk/test/java/lang/invoke/CustomizedLambdaFormTest.java
author alanb
Fri, 10 Feb 2017 09:04:39 +0000
changeset 43712 5dfd0950317c
parent 36511 9d0388c6b336
permissions -rw-r--r--
8173393: Module system implementation refresh (2/2017) Reviewed-by: dfuchs, psandoz, mchung, alanb Contributed-by: alan.bateman@oracle.com, mandy.chung@oracle.com, claes.redestad@oracle.com, alex.buckley@oracle.com, mark.reinhold@oracle.com, john.r.rose@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29221
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
     1
/*
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
     4
 *
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
     8
 *
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    13
 * accompanied this code).
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    14
 *
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    18
 *
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    21
 * questions.
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    22
 */
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    23
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 29221
diff changeset
    24
import java.lang.invoke.MethodHandle;
9d0388c6b336 8142968: Module System implementation
alanb
parents: 29221
diff changeset
    25
import java.lang.invoke.MethodHandleHelper;
9d0388c6b336 8142968: Module System implementation
alanb
parents: 29221
diff changeset
    26
import java.lang.invoke.MethodType;
29221
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    27
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    28
/* @test
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    29
 * @summary Assertion in LambdaFormEditor.bindArgumentType is too strong
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    30
 *
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 29221
diff changeset
    31
 * @compile/module=java.base java/lang/invoke/MethodHandleHelper.java
9d0388c6b336 8142968: Module System implementation
alanb
parents: 29221
diff changeset
    32
 * @run main/othervm -esa CustomizedLambdaFormTest
29221
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    33
 */
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 29221
diff changeset
    34
29221
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    35
public class CustomizedLambdaFormTest {
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    36
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    37
    static void testExtendCustomizedBMH() throws Exception {
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    38
        // Construct BMH
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 29221
diff changeset
    39
        MethodHandle mh = MethodHandleHelper.IMPL_LOOKUP.findVirtual(String.class, "concat",
29221
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    40
                MethodType.methodType(String.class, String.class))
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    41
                .bindTo("a");
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 29221
diff changeset
    42
        MethodHandleHelper.customize(mh);
29221
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    43
        mh.bindTo("b"); // Try to extend customized BMH
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    44
    }
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    45
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    46
    public static void main(String[] args) throws Throwable {
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    47
        testExtendCustomizedBMH();
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    48
    }
e946919cf487 8073644: Assertion in LambdaFormEditor.bindArgumentType is too strict
vlivanov
parents:
diff changeset
    49
}