1 /* 2 * Copyright (c) 2008, 2018, 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 * @test 26 * 27 * @summary converted from VM Testbase jit/t/t058. 28 * VM Testbase keywords: [jit, quick] 29 * 30 * @library /vmTestbase 31 * /test/lib 32 * @run driver jdk.test.lib.FileInstaller . . 33 * @build jit.t.t058.t058 34 * @run driver ExecDriver --java jit.t.t058.t058 35 */ 36 37 package jit.t.t058; 38 39 import nsk.share.TestFailure; 40 import nsk.share.GoldChecker; 41 42 interface l 43 { 44 void voodoo(); 45 } 46 47 class k implements l 48 { 49 double d; 50 long l; 51 int i; 52 float f; 53 short s; 54 char c; 55 byte b; 56 57 static double sd; 58 static long sl; 59 static int si; 60 static float sf; 61 static short ss; 62 static char sc; 63 static byte sb; 64 65 int value; 66 67 private int voodooCount; 68 69 k() 70 { 71 value = 0; 72 } 73 74 k(int n) 75 { 76 value = n; 77 } 78 79 public void voodoo() 80 { 81 voodooCount += 1; 82 t058.goldChecker.println("Voodoo " + voodooCount); 83 } 84 } 85 86 class t058 87 { 88 public static final GoldChecker goldChecker = new GoldChecker( "t058" ); 89 90 public static void main(String argv[]) 91 { 92 k ko; 93 l lo; 94 k ka[]; 95 k kaaa[][][]; 96 Object o; 97 boolean b; 98 int i,j,z; 99 100 ko = new k(); 101 ko.voodoo(); 102 lo = ko; 103 lo.voodoo(); 104 ka = new k[2]; 105 t058.goldChecker.println(ka.getClass().getName()); 106 kaaa = new k[2][2][2]; 107 t058.goldChecker.println(kaaa.getClass().getName()); 108 109 o = ka; 110 t058.goldChecker.println(o.getClass().getName()); 111 o = kaaa; 112 t058.goldChecker.println(o.getClass().getName()); 113 o = ko; 114 t058.goldChecker.println(o.getClass().getName()); 115 ko = (k) o; 116 t058.goldChecker.println(ko.getClass().getName()); 117 b = o instanceof k; 118 t058.goldChecker.println("o instanceof k: " + b); 119 lo.voodoo(); 120 121 o = new Object(); 122 t058.goldChecker.println(o.getClass().getName()); 123 124 t058.goldChecker.println(); 125 t058.goldChecker.println("Here come the instance variables of ko:"); 126 127 ko.d = 39.0; 128 ko.l = 40; 129 ko.i = 41; 130 ko.f = 42.0f; 131 ko.s = (short) 43; 132 ko.c = (char) 44; 133 ko.b = (byte) 45; 134 135 t058.goldChecker.println(ko.d); 136 t058.goldChecker.println(ko.l); 137 t058.goldChecker.println(ko.i); 138 t058.goldChecker.println(ko.f); 139 t058.goldChecker.println((int) ko.s); 140 t058.goldChecker.println((int) ko.c); 141 t058.goldChecker.println((int) ko.b); 142 143 144 t058.goldChecker.println(); 145 t058.goldChecker.println("Here come the static variables of k:"); 146 147 k.sd = 46.0; 148 k.sl = 47; 149 k.si = 48; 150 k.sf = 49.0f; 151 k.ss = (short) 50; 152 k.sc = (char) 51; 153 k.sb = (byte) 52; 154 155 t058.goldChecker.println(k.sd); 156 t058.goldChecker.println(k.sl); 157 t058.goldChecker.println(k.si); 158 t058.goldChecker.println(k.sf); 159 t058.goldChecker.println((int) k.ss); 160 t058.goldChecker.println((int) k.sc); 161 t058.goldChecker.println((int) k.sb); 162 163 /* Initialize the arrays. */ 164 for(i=0; i<2; i+=1) 165 { 166 ka[i] = new k(i); 167 for(j=0; j<2; j+=1) 168 { 169 for(z=0; z<2; z+=1) 170 { 171 kaaa[i][j][z] = new k(100*i + 10*j + z); 172 } 173 } 174 } 175 176 /* Display the arrays. */ 177 t058.goldChecker.println(); 178 t058.goldChecker.println("Here come the array values"); 179 for(i=0; i<2; i+=1) 180 { 181 t058.goldChecker.println(ka[i].value); 182 for(j=0; j<2; j+=1) 183 { 184 for(z=0; z<2; z+=1) 185 { 186 t058.goldChecker.println(kaaa[i][j][z].value); 187 } 188 } 189 if (i < 1) { 190 t058.goldChecker.println(); 191 } 192 } 193 t058.goldChecker.check(); 194 } 195 }