rfield@1422: /* katleman@1448: * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. rfield@1422: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. rfield@1422: * rfield@1422: * This code is free software; you can redistribute it and/or modify it rfield@1422: * under the terms of the GNU General Public License version 2 only, as rfield@1422: * published by the Free Software Foundation. Oracle designates this rfield@1422: * particular file as subject to the "Classpath" exception as provided rfield@1422: * by Oracle in the LICENSE file that accompanied this code. rfield@1422: * rfield@1422: * This code is distributed in the hope that it will be useful, but WITHOUT rfield@1422: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or rfield@1422: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License rfield@1422: * version 2 for more details (a copy is included in the LICENSE file that rfield@1422: * accompanied this code). rfield@1422: * rfield@1422: * You should have received a copy of the GNU General Public License version rfield@1422: * 2 along with this work; if not, write to the Free Software Foundation, rfield@1422: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. rfield@1422: * rfield@1422: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA rfield@1422: * or visit www.oracle.com if you need additional information or have any rfield@1422: * questions. rfield@1422: */ rfield@1422: rfield@1422: /** rfield@1422: * @test rfield@1422: * @bug 8003639 rfield@1422: * @summary convert lambda testng tests to jtreg and add them rfield@1422: * @run testng MethodReferenceTestSueCase4 rfield@1422: */ rfield@1422: rfield@1422: import org.testng.annotations.Test; rfield@1422: rfield@1422: import static org.testng.Assert.assertEquals; rfield@1422: rfield@1422: /** rfield@1422: * @author Robert Field rfield@1422: */ rfield@1422: rfield@1422: @Test rfield@1422: public class MethodReferenceTestSueCase4 { rfield@1422: rfield@1422: public interface Sam2 { public String get(T target, String s); } rfield@1422: rfield@1422: Sam2 var = new Object().equals(new Object()) ? Target::instanceMethod : Target::instanceMethod; rfield@1422: rfield@1422: String m() { rfield@1422: return var.get(new Target(), ""); rfield@1422: } rfield@1422: rfield@1422: static class Target { rfield@1422: String instanceMethod(String s) { return "2"; } rfield@1422: } rfield@1422: rfield@1422: public void testSueCase4() { rfield@1422: assertEquals(m(), "2"); rfield@1422: } rfield@1422: }