Sat, 22 Dec 2018 13:10:38 -0800
Added tag jdk8u202-b25 for changeset 15d8c732039b
rpatil@3092 | 1 | /* |
rpatil@3092 | 2 | * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
rpatil@3092 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
rpatil@3092 | 4 | * |
rpatil@3092 | 5 | * This code is free software; you can redistribute it and/or modify it |
rpatil@3092 | 6 | * under the terms of the GNU General Public License version 2 only, as |
rpatil@3092 | 7 | * published by the Free Software Foundation. |
rpatil@3092 | 8 | * |
rpatil@3092 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
rpatil@3092 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
rpatil@3092 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
rpatil@3092 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
rpatil@3092 | 13 | * accompanied this code). |
rpatil@3092 | 14 | * |
rpatil@3092 | 15 | * You should have received a copy of the GNU General Public License version |
rpatil@3092 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
rpatil@3092 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
rpatil@3092 | 18 | * |
rpatil@3092 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
rpatil@3092 | 20 | * or visit www.oracle.com if you need additional information or have any |
rpatil@3092 | 21 | * questions. |
rpatil@3092 | 22 | */ |
rpatil@3092 | 23 | |
rpatil@3092 | 24 | /* |
rpatil@3092 | 25 | * @test |
rpatil@3092 | 26 | * @bug 8066871 |
rpatil@3092 | 27 | * @summary java.lang.VerifyError: Bad local variable type - local final String |
rpatil@3092 | 28 | * @author Srikanth Sankaran |
rpatil@3092 | 29 | * |
rpatil@3092 | 30 | * @compile -g:none ConditionalWithFinalStrings.java |
rpatil@3092 | 31 | * @run main ConditionalWithFinalStrings |
rpatil@3092 | 32 | */ |
rpatil@3092 | 33 | |
rpatil@3092 | 34 | public class ConditionalWithFinalStrings { |
rpatil@3092 | 35 | |
rpatil@3092 | 36 | interface I { |
rpatil@3092 | 37 | String foo(); |
rpatil@3092 | 38 | } |
rpatil@3092 | 39 | |
rpatil@3092 | 40 | static class Tmp { |
rpatil@3092 | 41 | private String value; |
rpatil@3092 | 42 | public void setValue(String tmpStr) { |
rpatil@3092 | 43 | this.value = tmpStr; |
rpatil@3092 | 44 | if (!this.value.equals("YES")) |
rpatil@3092 | 45 | throw new AssertionError(); |
rpatil@3092 | 46 | } |
rpatil@3092 | 47 | } |
rpatil@3092 | 48 | |
rpatil@3092 | 49 | void goo(I i) { |
rpatil@3092 | 50 | if (!i.foo().equals("YES")) |
rpatil@3092 | 51 | throw new AssertionError(); |
rpatil@3092 | 52 | } |
rpatil@3092 | 53 | |
rpatil@3092 | 54 | public void test() { |
rpatil@3092 | 55 | final String y = "YES"; |
rpatil@3092 | 56 | final String n = "NO"; |
rpatil@3092 | 57 | Tmp tmp = new Tmp(); |
rpatil@3092 | 58 | tmp.setValue(true ? y : n); |
rpatil@3092 | 59 | goo (() -> y); |
rpatil@3092 | 60 | |
rpatil@3092 | 61 | } |
rpatil@3092 | 62 | public static void main(String[] args) { |
rpatil@3092 | 63 | new ConditionalWithFinalStrings().test(); |
rpatil@3092 | 64 | if (!id("Hello!").equals("Hello!")) |
rpatil@3092 | 65 | throw new AssertionError(); |
rpatil@3092 | 66 | |
rpatil@3092 | 67 | } |
rpatil@3092 | 68 | static <Z> Z id(Z z) { return z; } |
rpatil@3092 | 69 | } |