1 /* 2 * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 /** 26 * @test 27 * @bug 7103261 28 * @summary crash with jittester on sparc 29 * 30 * @run main Test7103261 31 */ 32 33 // exercise implicit null checking in the compiler for various field types 34 public class Test7103261 { 35 static Test7103261 null_value; 36 static Test7103261 nonnull_value = new Test7103261(); 37 static Test7103261 nonnull_value2 = new Test7103261(); 38 39 long l; 40 int i; 41 float f; 42 double d; 43 byte b; 44 char c; 45 short s; 46 boolean z; 47 Object o; 48 49 public static void main(String[] args) { 50 constantStore(); 51 valueTest(false); 52 valueTest(true); 53 } 54 static void constantStore() { 55 for (int field = 0; field < 9; field++) { 56 try { 57 Test7103261 o = nonnull_value; 58 for (int i = 0; i < 100000; i++) { 59 switch (field) { 60 case 0: o.l = 0; break; 61 case 1: o.i = 0; break; 62 case 2: o.f = 0; break; 63 case 3: o.d = 0; break; 64 case 4: o.b = 0; break; 65 case 5: o.c = 0; break; 66 case 6: o.s = 0; break; 67 case 7: o.z = false; break; 68 case 8: o.o = null; break; 69 default: throw new InternalError(); 70 } 71 if (i == 90000) { 72 // hide nullness from optimizer 73 o = null_value; 74 } 75 } 76 } catch (NullPointerException npe) { 77 } 78 } 79 } 80 static void valueTest(boolean store) { 81 for (int field = 0; field < 9; field++) { 82 try { 83 Test7103261 o = nonnull_value; 84 Test7103261 o2 = nonnull_value2; 85 for (int i = 0; i < 100000; i++) { 86 switch (field) { 87 case 0: o.l = o2.l; break; 88 case 1: o.i = o2.i; break; 89 case 2: o.f = o2.f; break; 90 case 3: o.d = o2.d; break; 91 case 4: o.b = o2.b; break; 92 case 5: o.c = o2.c; break; 93 case 6: o.s = o2.s; break; 94 case 7: o.z = o2.z; break; 95 case 8: o.o = o2.o; break; 96 default: throw new InternalError(); 97 } 98 if (i == 90000) { 99 // hide nullness from optimizer 100 if (store) 101 o = null_value; 102 else 103 o2 = null_value; 104 } 105 } 106 } catch (NullPointerException npe) { 107 } 108 } 109 } 110 }