rpatil@3092: /* rpatil@3092: * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. rpatil@3092: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. rpatil@3092: * rpatil@3092: * This code is free software; you can redistribute it and/or modify it rpatil@3092: * under the terms of the GNU General Public License version 2 only, as rpatil@3092: * published by the Free Software Foundation. rpatil@3092: * rpatil@3092: * This code is distributed in the hope that it will be useful, but WITHOUT rpatil@3092: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or rpatil@3092: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License rpatil@3092: * version 2 for more details (a copy is included in the LICENSE file that rpatil@3092: * accompanied this code). rpatil@3092: * rpatil@3092: * You should have received a copy of the GNU General Public License version rpatil@3092: * 2 along with this work; if not, write to the Free Software Foundation, rpatil@3092: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. rpatil@3092: * rpatil@3092: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA rpatil@3092: * or visit www.oracle.com if you need additional information or have any rpatil@3092: * questions. rpatil@3092: */ rpatil@3092: rpatil@3092: /* rpatil@3092: * @test rpatil@3092: * @bug 8066871 rpatil@3092: * @summary java.lang.VerifyError: Bad local variable type - local final String rpatil@3092: * @author Srikanth Sankaran rpatil@3092: * rpatil@3092: * @compile -g:none ConditionalWithFinalStrings.java rpatil@3092: * @run main ConditionalWithFinalStrings rpatil@3092: */ rpatil@3092: rpatil@3092: public class ConditionalWithFinalStrings { rpatil@3092: rpatil@3092: interface I { rpatil@3092: String foo(); rpatil@3092: } rpatil@3092: rpatil@3092: static class Tmp { rpatil@3092: private String value; rpatil@3092: public void setValue(String tmpStr) { rpatil@3092: this.value = tmpStr; rpatil@3092: if (!this.value.equals("YES")) rpatil@3092: throw new AssertionError(); rpatil@3092: } rpatil@3092: } rpatil@3092: rpatil@3092: void goo(I i) { rpatil@3092: if (!i.foo().equals("YES")) rpatil@3092: throw new AssertionError(); rpatil@3092: } rpatil@3092: rpatil@3092: public void test() { rpatil@3092: final String y = "YES"; rpatil@3092: final String n = "NO"; rpatil@3092: Tmp tmp = new Tmp(); rpatil@3092: tmp.setValue(true ? y : n); rpatil@3092: goo (() -> y); rpatil@3092: rpatil@3092: } rpatil@3092: public static void main(String[] args) { rpatil@3092: new ConditionalWithFinalStrings().test(); rpatil@3092: if (!id("Hello!").equals("Hello!")) rpatil@3092: throw new AssertionError(); rpatil@3092: rpatil@3092: } rpatil@3092: static Z id(Z z) { return z; } rpatil@3092: }