roland@6313: /* roland@6313: * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. roland@6313: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. roland@6313: * roland@6313: * This code is free software; you can redistribute it and/or modify it roland@6313: * under the terms of the GNU General Public License version 2 only, as roland@6313: * published by the Free Software Foundation. roland@6313: * roland@6313: * This code is distributed in the hope that it will be useful, but WITHOUT roland@6313: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or roland@6313: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License roland@6313: * version 2 for more details (a copy is included in the LICENSE file that roland@6313: * accompanied this code). roland@6313: * roland@6313: * You should have received a copy of the GNU General Public License version roland@6313: * 2 along with this work; if not, write to the Free Software Foundation, roland@6313: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. roland@6313: * roland@6313: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA roland@6313: * or visit www.oracle.com if you need additional information or have any roland@6313: * questions. roland@6313: */ roland@6313: roland@6313: /* roland@6313: * @test roland@6313: * @bug 8027422 roland@6313: * @summary type methods shouldn't always operate on speculative part roland@6313: * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:TypeProfileLevel=222 -XX:+UnlockExperimentalVMOptions -XX:+UseTypeSpeculation -XX:-BackgroundCompilation TestSpeculationFailedHigherEqual roland@6313: * roland@6313: */ roland@6313: roland@6313: public class TestSpeculationFailedHigherEqual { roland@6313: roland@6313: static class A { roland@6313: void m() {} roland@6313: int i; roland@6313: } roland@6313: roland@6313: static class C extends A { roland@6313: } roland@6313: roland@6313: static C c; roland@6313: roland@6313: static A m1(A a, boolean cond) { roland@6313: // speculative type for a is C not null roland@6313: if (cond ) { roland@6313: a = c; roland@6313: } roland@6313: // speculative type for a is C (may be null) roland@6313: int i = a.i; roland@6313: return a; roland@6313: } roland@6313: roland@6313: static public void main(String[] args) { roland@6313: C c = new C(); roland@6313: TestSpeculationFailedHigherEqual.c = c; roland@6313: for (int i = 0; i < 20000; i++) { roland@6313: m1(c, i%2 == 0); roland@6313: } roland@6313: roland@6313: System.out.println("TEST PASSED"); roland@6313: } roland@6313: }