langtools/test/tools/javac/lambda/MethodReferenceVarargsTest.java
author sadayapalam
Tue, 17 Jan 2017 09:17:10 +0530
changeset 43148 9d11c46bd7bf
permissions -rw-r--r--
8171993: AssertionError when compiling method reference with generic code and varargs. Reviewed-by: mcimadamore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43148
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
     1
/*
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
     4
 *
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
     8
 *
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    13
 * accompanied this code).
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    14
 *
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    18
 *
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    21
 * questions.
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    22
 */
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    23
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    24
/*
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    25
 * @test
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    26
 * @bug 8171993
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    27
 * @summary AssertionError when compiling method reference with generic code and varargs.
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    28
 * @compile MethodReferenceVarargsTest.java
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    29
 */
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    30
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    31
public class MethodReferenceVarargsTest<T> {
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    32
    public T invoke(Object... args) {
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    33
        return null;
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    34
    }
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    35
    public static <T extends String> void test() { // works with <T> alone.
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    36
        MethodReferenceVarargsTest<T> bug = new MethodReferenceVarargsTest<>();
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    37
        java.util.function.Function<String, T> b = bug::invoke;
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    38
        java.util.function.Function<String, T> f = (args) -> bug.invoke(args);
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    39
    }
9d11c46bd7bf 8171993: AssertionError when compiling method reference with generic code and varargs.
sadayapalam
parents:
diff changeset
    40
}