2890N/A/*
2890N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
2890N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2890N/A *
2890N/A * This code is free software; you can redistribute it and/or modify it
2890N/A * under the terms of the GNU General Public License version 2 only, as
2890N/A * published by the Free Software Foundation.
2890N/A *
2890N/A * This code is distributed in the hope that it will be useful, but WITHOUT
2890N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2890N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2890N/A * version 2 for more details (a copy is included in the LICENSE file that
2890N/A * accompanied this code).
2890N/A *
2890N/A * You should have received a copy of the GNU General Public License version
2890N/A * 2 along with this work; if not, write to the Free Software Foundation,
2890N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2890N/A *
2890N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2890N/A * or visit www.oracle.com if you need additional information or have any
2890N/A * questions.
2890N/A *
2890N/A */
2890N/A
2890N/A/**
2890N/A * @test
2890N/A * @bug 7103261
2890N/A * @summary crash with jittester on sparc
2890N/A *
2890N/A * @run main Test7103261
2890N/A */
2890N/A
2890N/A// exercise implicit null checking in the compiler for various field types
2890N/Apublic class Test7103261 {
2890N/A static Test7103261 null_value;
2890N/A static Test7103261 nonnull_value = new Test7103261();
2890N/A static Test7103261 nonnull_value2 = new Test7103261();
2890N/A
2890N/A long l;
2890N/A int i;
2890N/A float f;
2890N/A double d;
2890N/A byte b;
2890N/A char c;
2890N/A short s;
2890N/A boolean z;
2890N/A
2890N/A public static void main(String[] args) {
2890N/A constantStore();
2890N/A valueTest(false);
2890N/A valueTest(true);
2890N/A }
2890N/A static void constantStore() {
2890N/A for (int field = 0; field < 8; field++) {
2890N/A try {
2890N/A Test7103261 o = nonnull_value;
2890N/A for (int i = 0; i < 100000; i++) {
2890N/A switch (field) {
2890N/A case 0: o.l = 0; break;
2890N/A case 1: o.i = 0; break;
2890N/A case 2: o.f = 0; break;
2890N/A case 3: o.d = 0; break;
2890N/A case 4: o.b = 0; break;
2890N/A case 5: o.c = 0; break;
2890N/A case 6: o.s = 0; break;
2890N/A case 7: o.z = false; break;
2890N/A default: throw new InternalError();
2890N/A }
2890N/A if (i == 90000) {
2890N/A // hide nullness from optimizer
2890N/A o = null_value;
2890N/A }
2890N/A }
2890N/A } catch (NullPointerException npe) {
2890N/A }
2890N/A }
2890N/A }
2890N/A static void valueTest(boolean store) {
2890N/A for (int field = 0; field < 8; field++) {
2890N/A try {
2890N/A Test7103261 o = nonnull_value;
2890N/A Test7103261 o2 = nonnull_value2;
2890N/A for (int i = 0; i < 100000; i++) {
2890N/A switch (field) {
2890N/A case 0: o.l = o2.l; break;
2890N/A case 1: o.i = o2.i; break;
2890N/A case 2: o.f = o2.f; break;
2890N/A case 3: o.d = o2.d; break;
2890N/A case 4: o.b = o2.b; break;
2890N/A case 5: o.c = o2.c; break;
2890N/A case 6: o.s = o2.s; break;
2890N/A case 7: o.z = o2.z; break;
2890N/A default: throw new InternalError();
2890N/A }
2890N/A if (i == 90000) {
2890N/A // hide nullness from optimizer
2890N/A if (store)
2890N/A o = null_value;
2890N/A else
2890N/A o2 = null_value;
2890N/A }
2890N/A }
2890N/A } catch (NullPointerException npe) {
2890N/A }
2890N/A }
2890N/A }
2890N/A}