Path: blob/master/test/hotspot/jtreg/vmTestbase/jit/t/t020/t020.java
40948 views
/*1* Copyright (c) 2008, 2020, 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*26* @summary converted from VM Testbase jit/t/t020.27* VM Testbase keywords: [jit, quick]28*29* @library /vmTestbase30* /test/lib31* @run main/othervm jit.t.t020.t02032*/3334package jit.t.t020;3536import nsk.share.TestFailure;37import nsk.share.GoldChecker;3839// opc_checkcast, opc_instanceof, opc_ifnull, opc_ifnonnull4041public class t02042{43public static final GoldChecker goldChecker = new GoldChecker( "t020" );4445private static void show(t020 x)46{47try48{49t020.goldChecker.print(" is a t020");50if(x instanceof k)51t020.goldChecker.print(" and also a k");52if(x == null)53t020.goldChecker.print(" and also null");54if(x != null)55t020.goldChecker.print(" and also not null");56t020.goldChecker.println(".");57}58catch(Throwable e)59{60t020.goldChecker.println(" " + e.getMessage());61}62}6364public static void main(String argv[])65{66t020 a[] = new t020[4];67t020 t = new k();68k u = null;69a[0] = new t020();70a[1] = t;71a[3] = u;7273for(int i=0; i<4; i+=1)74{75t020.goldChecker.print("a[" + i + "]");76show(a[i]);77}7879t020.goldChecker.println();80for(int i=0; i<4; i+=1)81{82try83{84t020.goldChecker.print("Assigning a[" + i + "] to u");85u = (k) a[i];86t020.goldChecker.print(" worked ok");87}88catch(Throwable x)89{90t020.goldChecker.print(" failed");91}92finally93{94t020.goldChecker.println(".");95}96}97t020.goldChecker.check();98}99100}101102class k extends t020103{104}105106107