783N/A/*
1472N/A * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
783N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
783N/A *
783N/A * This code is free software; you can redistribute it and/or modify it
783N/A * under the terms of the GNU General Public License version 2 only, as
783N/A * published by the Free Software Foundation.
783N/A *
783N/A * This code is distributed in the hope that it will be useful, but WITHOUT
783N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
783N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
783N/A * version 2 for more details (a copy is included in the LICENSE file that
783N/A * accompanied this code).
783N/A *
783N/A * You should have received a copy of the GNU General Public License version
783N/A * 2 along with this work; if not, write to the Free Software Foundation,
783N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
783N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
783N/A *
783N/A */
783N/A
783N/A/*
783N/A * @test
783N/A * @bug 6832293
783N/A * @summary JIT compiler got wrong result in type checking with -server
783N/A * @run main/othervm -Xcomp -XX:CompileOnly=Test.run Test
783N/A */
783N/A
783N/Aimport java.io.PrintStream;
783N/A
783N/Ainterface SomeInterface {
783N/A int SEVENS = 777;
783N/A}
783N/A
783N/Ainterface AnotherInterface {
783N/A int THIRDS = 33;
783N/A}
783N/A
783N/Aclass SomeClass implements SomeInterface {
783N/A int i;
783N/A
783N/A SomeClass(int i) {
783N/A this.i = i;
783N/A }
783N/A}
783N/A
783N/Aclass ImmediateSubclass extends SomeClass implements SomeInterface {
783N/A float f;
783N/A
783N/A ImmediateSubclass(int i, float f) {
783N/A super(i);
783N/A this.f = f;
783N/A }
783N/A}
783N/A
783N/Afinal class FinalSubclass extends ImmediateSubclass implements AnotherInterface {
783N/A double d;
783N/A
783N/A FinalSubclass(int i, float f, double d) {
783N/A super(i, f);
783N/A this.d = d;
783N/A }
783N/A}
783N/A
783N/Apublic class Test {
783N/A
783N/A public static void main(String args[]) throws Exception{
783N/A /* try to pre initialize */
783N/A SomeClass[] a=new SomeClass[10];
783N/A Class.forName("ImmediateSubclass");
783N/A Class.forName("FinalSubclass");
783N/A System.exit(run(args, System.out) + 95/*STATUS_TEMP*/);
783N/A }
783N/A
783N/A static int errorStatus = 0/*STATUS_PASSED*/;
783N/A
783N/A static void errorAlert(PrintStream out, int errorLevel) {
783N/A out.println("Test: failure #" + errorLevel);
783N/A errorStatus = 2/*STATUS_FAILED*/;
783N/A }
783N/A
783N/A static SomeClass[] v2 = new FinalSubclass[4];
783N/A
783N/A public static int run(String args[],PrintStream out) {
783N/A int i [], j [];
783N/A SomeInterface u [], v[] [];
783N/A AnotherInterface w [];
783N/A SomeClass x [] [];
783N/A
783N/A i = new int [10];
783N/A i[0] = 777;
783N/A j = (int []) i;
783N/A if (j != i)
783N/A errorAlert(out, 2);
783N/A else if (j.length != 10)
783N/A errorAlert(out, 3);
783N/A else if (j[0] != 777)
783N/A errorAlert(out, 4);
783N/A
783N/A v = new SomeClass [3] [];
783N/A x = (SomeClass [] []) v;
783N/A if (! (x instanceof SomeInterface [] []))
783N/A errorAlert(out, 5);
783N/A else if (! (x instanceof SomeClass [] []))
783N/A errorAlert(out, 6);
783N/A else if (x != v)
783N/A errorAlert(out, 7);
783N/A
783N/A x[0] = (SomeClass []) new ImmediateSubclass [4];
783N/A if (! (x[0] instanceof ImmediateSubclass []))
783N/A errorAlert(out, 8);
783N/A else if (x[0].length != 4)
783N/A errorAlert(out, 9);
783N/A
783N/A x[1] = (SomeClass []) v2;
783N/A if (! (x[1] instanceof FinalSubclass []))
783N/A errorAlert(out, 10);
783N/A else if (x[1].length != 4)
783N/A errorAlert(out, 11);
783N/A
783N/A w = (AnotherInterface []) x[1];
783N/A if (! (w instanceof FinalSubclass []))
783N/A errorAlert(out, 12);
783N/A else if (w != x[1])
783N/A errorAlert(out, 13);
783N/A else if (w.length != 4)
783N/A errorAlert(out, 14);
783N/A
783N/A return errorStatus;
783N/A }
783N/A}
783N/A