test/tools/javac/conditional/6500343/T6500343a.java

Wed, 14 Nov 2018 10:18:25 -0800

author
diazhou
date
Wed, 14 Nov 2018 10:18:25 -0800
changeset 3762
7909abb85562
parent 554
9d9f26857129
child 2525
2eb010b6cb22
permissions
-rw-r--r--

Added tag jdk8u201-b04 for changeset a7f48b9dfb82

mcimadamore@120 1 /*
ohair@554 2 * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
mcimadamore@120 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
mcimadamore@120 4 *
mcimadamore@120 5 * This code is free software; you can redistribute it and/or modify it
mcimadamore@120 6 * under the terms of the GNU General Public License version 2 only, as
mcimadamore@120 7 * published by the Free Software Foundation.
mcimadamore@120 8 *
mcimadamore@120 9 * This code is distributed in the hope that it will be useful, but WITHOUT
mcimadamore@120 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
mcimadamore@120 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
mcimadamore@120 12 * version 2 for more details (a copy is included in the LICENSE file that
mcimadamore@120 13 * accompanied this code).
mcimadamore@120 14 *
mcimadamore@120 15 * You should have received a copy of the GNU General Public License version
mcimadamore@120 16 * 2 along with this work; if not, write to the Free Software Foundation,
mcimadamore@120 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
mcimadamore@120 18 *
ohair@554 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 20 * or visit www.oracle.com if you need additional information or have any
ohair@554 21 * questions.
mcimadamore@120 22 */
mcimadamore@120 23
mcimadamore@120 24 /*
mcimadamore@120 25 * @test
mcimadamore@120 26 * @bug 6500343
mcimadamore@120 27 * @summary compiler generates bad code when translating conditional expressions
mcimadamore@120 28 * @author Maurizio Cimadamore
mcimadamore@120 29 *
mcimadamore@120 30 */
mcimadamore@120 31
mcimadamore@120 32 public class T6500343a {
mcimadamore@120 33 static class Base {}
mcimadamore@120 34 static interface I {}
mcimadamore@120 35 static class A1 extends Base implements I {}
mcimadamore@120 36 static class A2 extends Base implements I {}
mcimadamore@120 37
mcimadamore@120 38 static Object crash(I i, A1 a1, A2 a2, boolean b1, boolean b2) {
mcimadamore@120 39 return b1 ? i : b2 ? a2 : a1;
mcimadamore@120 40 // lub(I, lub(A1, A2)) ==> lub(I, Base&I) ==> I (doesn't compile on 1.4 ok >1.5)
mcimadamore@120 41 }
mcimadamore@120 42
mcimadamore@120 43 public static void main(String[] args) {
mcimadamore@120 44 T6500343a.crash(new A1(), new A1(), new A2(), true, false);
mcimadamore@120 45 T6500343a.crash(new A1(), new A1(), new A2(), false, true);
mcimadamore@120 46 T6500343a.crash(new A1(), new A1(), new A2(), false, false);
mcimadamore@120 47 T6500343a.crash(new A1(), new A1(), new A2(), true, true);
mcimadamore@120 48 }
mcimadamore@120 49 }
mcimadamore@120 50

mercurial