Path: blob/master/test/hotspot/jtreg/compiler/intrinsics/object/TestHashCode.java
41153 views
/*1* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 801164626* @summary SEGV in compiled code with loop predication27*28* @run main/othervm -XX:-TieredCompilation29* -XX:CompileCommand=compileonly,java.lang.Object::hashCode30* -XX:CompileCommand=compileonly,compiler.intrinsics.object.TestHashCode::m131* compiler.intrinsics.object.TestHashCode32*/3334package compiler.intrinsics.object;3536public class TestHashCode {37static class A {38int i;39}4041static class B extends A {42}4344static boolean crash = false;4546static A m2() {47if (crash) {48return null;49}50return new A();51}5253static int m1(A aa) {54int res = 0;55for (int i = 0; i < 10; i++) {56A a = m2();57int j = a.i;58if (aa instanceof B) {59}60res += a.hashCode();61}62return res;63}6465public static void main(String[] args) {66A a = new A();67for (int i = 0; i < 20000; i++) {68m1(a);69}70crash = true;71try {72m1(a);73} catch (NullPointerException e) {74System.out.println("Test passed");75}76}77}787980