Path: blob/master/test/hotspot/jtreg/compiler/c2/Test6832293.java
41149 views
/*1* Copyright (c) 2008, 2009, 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 683229326* @summary JIT compiler got wrong result in type checking with -server27*28* @run main/othervm -Xcomp29* -XX:CompileCommand=compileonly,compiler.c2.Test6832293::run30* compiler.c2.Test683229331*/3233package compiler.c2;3435import java.io.PrintStream;3637public class Test6832293 {38static interface SomeInterface {39int SEVENS = 777;40}4142static interface AnotherInterface {43int THIRDS = 33;44}4546static class SomeClass implements SomeInterface {47int i;4849SomeClass(int i) {50this.i = i;51}52}5354static class ImmediateSubclass extends SomeClass implements SomeInterface {55float f;5657ImmediateSubclass(int i, float f) {58super(i);59this.f = f;60}61}6263static final class FinalSubclass extends ImmediateSubclass implements AnotherInterface {64double d;6566FinalSubclass(int i, float f, double d) {67super(i, f);68this.d = d;69}70}7172public static void main(String args[]) throws Exception{73/* try to pre initialize */74SomeClass[] a=new SomeClass[10];75String className = Test6832293.class.getName();76Class.forName(className + "$ImmediateSubclass");77Class.forName(className + "$FinalSubclass");78System.exit(run(args, System.out) + 95/*STATUS_TEMP*/);79}8081static int errorStatus = 0/*STATUS_PASSED*/;8283static void errorAlert(PrintStream out, int errorLevel) {84out.println("Test: failure #" + errorLevel);85errorStatus = 2/*STATUS_FAILED*/;86}8788static SomeClass[] v2 = new FinalSubclass[4];8990public static int run(String args[],PrintStream out) {91int i [], j [];92SomeInterface u [], v[] [];93AnotherInterface w [];94SomeClass x [] [];9596i = new int [10];97i[0] = 777;98j = (int []) i;99if (j != i)100errorAlert(out, 2);101else if (j.length != 10)102errorAlert(out, 3);103else if (j[0] != 777)104errorAlert(out, 4);105106v = new SomeClass [3] [];107x = (SomeClass [] []) v;108if (! (x instanceof SomeInterface [] []))109errorAlert(out, 5);110else if (! (x instanceof SomeClass [] []))111errorAlert(out, 6);112else if (x != v)113errorAlert(out, 7);114115x[0] = (SomeClass []) new ImmediateSubclass [4];116if (! (x[0] instanceof ImmediateSubclass []))117errorAlert(out, 8);118else if (x[0].length != 4)119errorAlert(out, 9);120121x[1] = (SomeClass []) v2;122if (! (x[1] instanceof FinalSubclass []))123errorAlert(out, 10);124else if (x[1].length != 4)125errorAlert(out, 11);126127w = (AnotherInterface []) x[1];128if (! (w instanceof FinalSubclass []))129errorAlert(out, 12);130else if (w != x[1])131errorAlert(out, 13);132else if (w.length != 4)133errorAlert(out, 14);134135return errorStatus;136}137}138139140141