Fri, 03 Dec 2010 06:14:37 -0800
7003798: test/compiler/6991596 fails with true != false
Summary: The test of 6991596 fails on SPARCV9.
Reviewed-by: kvn, never, jrose
twisti@2256 | 1 | /* |
twisti@2256 | 2 | * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. |
twisti@2256 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
twisti@2256 | 4 | * |
twisti@2256 | 5 | * This code is free software; you can redistribute it and/or modify it |
twisti@2256 | 6 | * under the terms of the GNU General Public License version 2 only, as |
twisti@2256 | 7 | * published by the Free Software Foundation. |
twisti@2256 | 8 | * |
twisti@2256 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
twisti@2256 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
twisti@2256 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
twisti@2256 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
twisti@2256 | 13 | * accompanied this code). |
twisti@2256 | 14 | * |
twisti@2256 | 15 | * You should have received a copy of the GNU General Public License version |
twisti@2256 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
twisti@2256 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
twisti@2256 | 18 | * |
twisti@2256 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
twisti@2256 | 20 | * or visit www.oracle.com if you need additional information or have any |
twisti@2256 | 21 | * questions. |
twisti@2256 | 22 | * |
twisti@2256 | 23 | */ |
twisti@2256 | 24 | |
twisti@2256 | 25 | /** |
twisti@2256 | 26 | * @test |
twisti@2256 | 27 | * @bug 6991596 |
twisti@2256 | 28 | * @summary JSR 292 unimplemented adapter_opt_i2i and adapter_opt_l2i on SPARC |
twisti@2256 | 29 | * |
twisti@2256 | 30 | * @run main/othervm -ea -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles -XX:+EnableInvokeDynamic -XX:+UnlockDiagnosticVMOptions -XX:+VerifyMethodHandles Test6991596 |
twisti@2256 | 31 | */ |
twisti@2256 | 32 | |
twisti@2256 | 33 | import java.dyn.*; |
twisti@2256 | 34 | |
twisti@2256 | 35 | public class Test6991596 { |
twisti@2256 | 36 | private static final Class CLASS = Test6991596.class; |
twisti@2256 | 37 | private static final String NAME = "foo"; |
twisti@2351 | 38 | private static final boolean DEBUG = System.getProperty("DEBUG", "false").equals("true"); |
twisti@2256 | 39 | |
twisti@2256 | 40 | public static void main(String[] args) throws Throwable { |
twisti@2256 | 41 | testboolean(); |
twisti@2256 | 42 | testbyte(); |
twisti@2256 | 43 | testchar(); |
twisti@2256 | 44 | testshort(); |
twisti@2256 | 45 | testint(); |
twisti@2256 | 46 | testlong(); |
twisti@2256 | 47 | } |
twisti@2256 | 48 | |
twisti@2256 | 49 | // Helpers to get various methods. |
twisti@2351 | 50 | static MethodHandle getmh1(Class ret, Class arg) throws NoAccessException { |
twisti@2256 | 51 | return MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(ret, arg)); |
twisti@2256 | 52 | } |
twisti@2256 | 53 | static MethodHandle getmh2(MethodHandle mh1, Class ret, Class arg) { |
twisti@2256 | 54 | return MethodHandles.convertArguments(mh1, MethodType.methodType(ret, arg)); |
twisti@2256 | 55 | } |
twisti@2256 | 56 | static MethodHandle getmh3(MethodHandle mh1, Class ret, Class arg) { |
twisti@2256 | 57 | return MethodHandles.convertArguments(mh1, MethodType.methodType(ret, arg)); |
twisti@2256 | 58 | } |
twisti@2256 | 59 | |
twisti@2256 | 60 | // test adapter_opt_i2i |
twisti@2256 | 61 | static void testboolean() throws Throwable { |
twisti@2256 | 62 | boolean[] a = new boolean[] { |
twisti@2256 | 63 | true, |
twisti@2256 | 64 | false |
twisti@2256 | 65 | }; |
twisti@2256 | 66 | for (int i = 0; i < a.length; i++) { |
twisti@2256 | 67 | doboolean(a[i]); |
twisti@2256 | 68 | } |
twisti@2256 | 69 | } |
twisti@2256 | 70 | static void doboolean(boolean x) throws Throwable { |
twisti@2256 | 71 | if (DEBUG) System.out.println("boolean=" + x); |
twisti@2256 | 72 | |
twisti@2256 | 73 | // boolean |
twisti@2256 | 74 | { |
twisti@2256 | 75 | MethodHandle mh1 = getmh1( boolean.class, boolean.class); |
twisti@2256 | 76 | MethodHandle mh2 = getmh2(mh1, boolean.class, boolean.class); |
twisti@2256 | 77 | // TODO add this for all cases when the bugs are fixed. |
twisti@2256 | 78 | //MethodHandle mh3 = getmh3(mh1, boolean.class, boolean.class); |
twisti@2351 | 79 | boolean a = (boolean) mh1.invokeExact((boolean) x); |
twisti@2351 | 80 | boolean b = (boolean) mh2.invokeExact(x); |
twisti@2256 | 81 | //boolean c = mh3.<boolean>invokeExact((boolean) x); |
twisti@2351 | 82 | check(x, a, b); |
twisti@2351 | 83 | //check(x, c, x); |
twisti@2256 | 84 | } |
twisti@2256 | 85 | |
twisti@2256 | 86 | // byte |
twisti@2256 | 87 | { |
twisti@2256 | 88 | MethodHandle mh1 = getmh1( byte.class, byte.class ); |
twisti@2256 | 89 | MethodHandle mh2 = getmh2(mh1, byte.class, boolean.class); |
twisti@2351 | 90 | byte a = (byte) mh1.invokeExact((byte) (x ? 1 : 0)); |
twisti@2351 | 91 | byte b = (byte) mh2.invokeExact(x); |
twisti@2351 | 92 | check(x, a, b); |
twisti@2256 | 93 | } |
twisti@2256 | 94 | |
twisti@2256 | 95 | // char |
twisti@2256 | 96 | { |
twisti@2256 | 97 | MethodHandle mh1 = getmh1( char.class, char.class); |
twisti@2256 | 98 | MethodHandle mh2 = getmh2(mh1, char.class, boolean.class); |
twisti@2351 | 99 | char a = (char) mh1.invokeExact((char) (x ? 1 : 0)); |
twisti@2351 | 100 | char b = (char) mh2.invokeExact(x); |
twisti@2351 | 101 | check(x, a, b); |
twisti@2256 | 102 | } |
twisti@2256 | 103 | |
twisti@2256 | 104 | // short |
twisti@2256 | 105 | { |
twisti@2256 | 106 | MethodHandle mh1 = getmh1( short.class, short.class); |
twisti@2256 | 107 | MethodHandle mh2 = getmh2(mh1, short.class, boolean.class); |
twisti@2351 | 108 | short a = (short) mh1.invokeExact((short) (x ? 1 : 0)); |
twisti@2351 | 109 | short b = (short) mh2.invokeExact(x); |
twisti@2351 | 110 | check(x, a, b); |
twisti@2256 | 111 | } |
twisti@2256 | 112 | } |
twisti@2256 | 113 | |
twisti@2256 | 114 | static void testbyte() throws Throwable { |
twisti@2256 | 115 | byte[] a = new byte[] { |
twisti@2256 | 116 | Byte.MIN_VALUE, |
twisti@2256 | 117 | Byte.MIN_VALUE + 1, |
twisti@2256 | 118 | -0x0F, |
twisti@2256 | 119 | -1, |
twisti@2256 | 120 | 0, |
twisti@2256 | 121 | 1, |
twisti@2256 | 122 | 0x0F, |
twisti@2256 | 123 | Byte.MAX_VALUE - 1, |
twisti@2256 | 124 | Byte.MAX_VALUE |
twisti@2256 | 125 | }; |
twisti@2256 | 126 | for (int i = 0; i < a.length; i++) { |
twisti@2256 | 127 | dobyte(a[i]); |
twisti@2256 | 128 | } |
twisti@2256 | 129 | } |
twisti@2256 | 130 | static void dobyte(byte x) throws Throwable { |
twisti@2256 | 131 | if (DEBUG) System.out.println("byte=" + x); |
twisti@2256 | 132 | |
twisti@2256 | 133 | // boolean |
twisti@2256 | 134 | { |
twisti@2256 | 135 | MethodHandle mh1 = getmh1( boolean.class, boolean.class); |
twisti@2256 | 136 | MethodHandle mh2 = getmh2(mh1, boolean.class, byte.class); |
twisti@2351 | 137 | boolean a = (boolean) mh1.invokeExact((x & 1) == 1); |
twisti@2351 | 138 | boolean b = (boolean) mh2.invokeExact(x); |
twisti@2351 | 139 | check(x, a, b); |
twisti@2256 | 140 | } |
twisti@2256 | 141 | |
twisti@2256 | 142 | // byte |
twisti@2256 | 143 | { |
twisti@2256 | 144 | MethodHandle mh1 = getmh1( byte.class, byte.class); |
twisti@2256 | 145 | MethodHandle mh2 = getmh2(mh1, byte.class, byte.class); |
twisti@2351 | 146 | byte a = (byte) mh1.invokeExact((byte) x); |
twisti@2351 | 147 | byte b = (byte) mh2.invokeExact(x); |
twisti@2351 | 148 | check(x, a, b); |
twisti@2256 | 149 | } |
twisti@2256 | 150 | |
twisti@2256 | 151 | // char |
twisti@2256 | 152 | { |
twisti@2256 | 153 | MethodHandle mh1 = getmh1( char.class, char.class); |
twisti@2256 | 154 | MethodHandle mh2 = getmh2(mh1, char.class, byte.class); |
twisti@2351 | 155 | char a = (char) mh1.invokeExact((char) x); |
twisti@2351 | 156 | char b = (char) mh2.invokeExact(x); |
twisti@2351 | 157 | check(x, a, b); |
twisti@2256 | 158 | } |
twisti@2256 | 159 | |
twisti@2256 | 160 | // short |
twisti@2256 | 161 | { |
twisti@2256 | 162 | MethodHandle mh1 = getmh1( short.class, short.class); |
twisti@2256 | 163 | MethodHandle mh2 = getmh2(mh1, short.class, byte.class); |
twisti@2351 | 164 | short a = (short) mh1.invokeExact((short) x); |
twisti@2351 | 165 | short b = (short) mh2.invokeExact(x); |
twisti@2351 | 166 | check(x, a, b); |
twisti@2256 | 167 | } |
twisti@2256 | 168 | } |
twisti@2256 | 169 | |
twisti@2256 | 170 | static void testchar() throws Throwable { |
twisti@2256 | 171 | char[] a = new char[] { |
twisti@2256 | 172 | Character.MIN_VALUE, |
twisti@2256 | 173 | Character.MIN_VALUE + 1, |
twisti@2256 | 174 | 0x000F, |
twisti@2256 | 175 | 0x00FF, |
twisti@2256 | 176 | 0x0FFF, |
twisti@2256 | 177 | Character.MAX_VALUE - 1, |
twisti@2256 | 178 | Character.MAX_VALUE |
twisti@2256 | 179 | }; |
twisti@2256 | 180 | for (int i = 0; i < a.length; i++) { |
twisti@2256 | 181 | dochar(a[i]); |
twisti@2256 | 182 | } |
twisti@2256 | 183 | } |
twisti@2256 | 184 | static void dochar(char x) throws Throwable { |
twisti@2256 | 185 | if (DEBUG) System.out.println("char=" + x); |
twisti@2256 | 186 | |
twisti@2256 | 187 | // boolean |
twisti@2256 | 188 | { |
twisti@2256 | 189 | MethodHandle mh1 = getmh1( boolean.class, boolean.class); |
twisti@2256 | 190 | MethodHandle mh2 = getmh2(mh1, boolean.class, char.class); |
twisti@2351 | 191 | boolean a = (boolean) mh1.invokeExact((x & 1) == 1); |
twisti@2351 | 192 | boolean b = (boolean) mh2.invokeExact(x); |
twisti@2351 | 193 | check(x, a, b); |
twisti@2256 | 194 | } |
twisti@2256 | 195 | |
twisti@2256 | 196 | // byte |
twisti@2256 | 197 | { |
twisti@2256 | 198 | MethodHandle mh1 = getmh1( byte.class, byte.class); |
twisti@2256 | 199 | MethodHandle mh2 = getmh2(mh1, byte.class, char.class); |
twisti@2351 | 200 | byte a = (byte) mh1.invokeExact((byte) x); |
twisti@2351 | 201 | byte b = (byte) mh2.invokeExact(x); |
twisti@2351 | 202 | check(x, a, b); |
twisti@2256 | 203 | } |
twisti@2256 | 204 | |
twisti@2256 | 205 | // char |
twisti@2256 | 206 | { |
twisti@2256 | 207 | MethodHandle mh1 = getmh1( char.class, char.class); |
twisti@2256 | 208 | MethodHandle mh2 = getmh2(mh1, char.class, char.class); |
twisti@2351 | 209 | char a = (char) mh1.invokeExact((char) x); |
twisti@2351 | 210 | char b = (char) mh2.invokeExact(x); |
twisti@2351 | 211 | check(x, a, b); |
twisti@2256 | 212 | } |
twisti@2256 | 213 | |
twisti@2256 | 214 | // short |
twisti@2256 | 215 | { |
twisti@2256 | 216 | MethodHandle mh1 = getmh1( short.class, short.class); |
twisti@2256 | 217 | MethodHandle mh2 = getmh2(mh1, short.class, char.class); |
twisti@2351 | 218 | short a = (short) mh1.invokeExact((short) x); |
twisti@2351 | 219 | short b = (short) mh2.invokeExact(x); |
twisti@2351 | 220 | check(x, a, b); |
twisti@2256 | 221 | } |
twisti@2256 | 222 | } |
twisti@2256 | 223 | |
twisti@2256 | 224 | static void testshort() throws Throwable { |
twisti@2256 | 225 | short[] a = new short[] { |
twisti@2256 | 226 | Short.MIN_VALUE, |
twisti@2256 | 227 | Short.MIN_VALUE + 1, |
twisti@2256 | 228 | -0x0FFF, |
twisti@2256 | 229 | -0x00FF, |
twisti@2256 | 230 | -0x000F, |
twisti@2256 | 231 | -1, |
twisti@2256 | 232 | 0, |
twisti@2256 | 233 | 1, |
twisti@2256 | 234 | 0x000F, |
twisti@2256 | 235 | 0x00FF, |
twisti@2256 | 236 | 0x0FFF, |
twisti@2256 | 237 | Short.MAX_VALUE - 1, |
twisti@2256 | 238 | Short.MAX_VALUE |
twisti@2256 | 239 | }; |
twisti@2256 | 240 | for (int i = 0; i < a.length; i++) { |
twisti@2256 | 241 | doshort(a[i]); |
twisti@2256 | 242 | } |
twisti@2256 | 243 | } |
twisti@2256 | 244 | static void doshort(short x) throws Throwable { |
twisti@2256 | 245 | if (DEBUG) System.out.println("short=" + x); |
twisti@2256 | 246 | |
twisti@2256 | 247 | // boolean |
twisti@2256 | 248 | { |
twisti@2256 | 249 | MethodHandle mh1 = getmh1( boolean.class, boolean.class); |
twisti@2256 | 250 | MethodHandle mh2 = getmh2(mh1, boolean.class, short.class); |
twisti@2351 | 251 | boolean a = (boolean) mh1.invokeExact((x & 1) == 1); |
twisti@2351 | 252 | boolean b = (boolean) mh2.invokeExact(x); |
twisti@2351 | 253 | check(x, a, b); |
twisti@2256 | 254 | } |
twisti@2256 | 255 | |
twisti@2256 | 256 | // byte |
twisti@2256 | 257 | { |
twisti@2256 | 258 | MethodHandle mh1 = getmh1( byte.class, byte.class); |
twisti@2256 | 259 | MethodHandle mh2 = getmh2(mh1, byte.class, short.class); |
twisti@2351 | 260 | byte a = (byte) mh1.invokeExact((byte) x); |
twisti@2351 | 261 | byte b = (byte) mh2.invokeExact(x); |
twisti@2351 | 262 | check(x, a, b); |
twisti@2256 | 263 | } |
twisti@2256 | 264 | |
twisti@2256 | 265 | // char |
twisti@2256 | 266 | { |
twisti@2256 | 267 | MethodHandle mh1 = getmh1( char.class, char.class); |
twisti@2256 | 268 | MethodHandle mh2 = getmh2(mh1, char.class, short.class); |
twisti@2351 | 269 | char a = (char) mh1.invokeExact((char) x); |
twisti@2351 | 270 | char b = (char) mh2.invokeExact(x); |
twisti@2351 | 271 | check(x, a, b); |
twisti@2256 | 272 | } |
twisti@2256 | 273 | |
twisti@2256 | 274 | // short |
twisti@2256 | 275 | { |
twisti@2256 | 276 | MethodHandle mh1 = getmh1( short.class, short.class); |
twisti@2256 | 277 | MethodHandle mh2 = getmh2(mh1, short.class, short.class); |
twisti@2351 | 278 | short a = (short) mh1.invokeExact((short) x); |
twisti@2351 | 279 | short b = (short) mh2.invokeExact(x); |
twisti@2351 | 280 | check(x, a, b); |
twisti@2256 | 281 | } |
twisti@2256 | 282 | } |
twisti@2256 | 283 | |
twisti@2256 | 284 | static void testint() throws Throwable { |
twisti@2256 | 285 | int[] a = new int[] { |
twisti@2256 | 286 | Integer.MIN_VALUE, |
twisti@2256 | 287 | Integer.MIN_VALUE + 1, |
twisti@2256 | 288 | -0x0FFFFFFF, |
twisti@2256 | 289 | -0x00FFFFFF, |
twisti@2256 | 290 | -0x000FFFFF, |
twisti@2256 | 291 | -0x0000FFFF, |
twisti@2256 | 292 | -0x00000FFF, |
twisti@2256 | 293 | -0x000000FF, |
twisti@2256 | 294 | -0x0000000F, |
twisti@2256 | 295 | -1, |
twisti@2256 | 296 | 0, |
twisti@2256 | 297 | 1, |
twisti@2256 | 298 | 0x0000000F, |
twisti@2256 | 299 | 0x000000FF, |
twisti@2256 | 300 | 0x00000FFF, |
twisti@2256 | 301 | 0x0000FFFF, |
twisti@2256 | 302 | 0x000FFFFF, |
twisti@2256 | 303 | 0x00FFFFFF, |
twisti@2256 | 304 | 0x0FFFFFFF, |
twisti@2256 | 305 | Integer.MAX_VALUE - 1, |
twisti@2256 | 306 | Integer.MAX_VALUE |
twisti@2256 | 307 | }; |
twisti@2256 | 308 | for (int i = 0; i < a.length; i++) { |
twisti@2256 | 309 | doint(a[i]); |
twisti@2256 | 310 | } |
twisti@2256 | 311 | } |
twisti@2256 | 312 | static void doint(int x) throws Throwable { |
twisti@2256 | 313 | if (DEBUG) System.out.println("int=" + x); |
twisti@2256 | 314 | |
twisti@2256 | 315 | // boolean |
twisti@2256 | 316 | { |
twisti@2256 | 317 | MethodHandle mh1 = getmh1( boolean.class, boolean.class); |
twisti@2256 | 318 | MethodHandle mh2 = getmh2(mh1, boolean.class, int.class); |
twisti@2351 | 319 | boolean a = (boolean) mh1.invokeExact((x & 1) == 1); |
twisti@2351 | 320 | boolean b = (boolean) mh2.invokeExact(x); |
twisti@2351 | 321 | check(x, a, b); |
twisti@2256 | 322 | } |
twisti@2256 | 323 | |
twisti@2256 | 324 | // byte |
twisti@2256 | 325 | { |
twisti@2256 | 326 | MethodHandle mh1 = getmh1( byte.class, byte.class); |
twisti@2256 | 327 | MethodHandle mh2 = getmh2(mh1, byte.class, int.class); |
twisti@2351 | 328 | byte a = (byte) mh1.invokeExact((byte) x); |
twisti@2351 | 329 | byte b = (byte) mh2.invokeExact(x); |
twisti@2351 | 330 | check(x, a, b); |
twisti@2256 | 331 | } |
twisti@2256 | 332 | |
twisti@2256 | 333 | // char |
twisti@2256 | 334 | { |
twisti@2256 | 335 | MethodHandle mh1 = getmh1( char.class, char.class); |
twisti@2256 | 336 | MethodHandle mh2 = getmh2(mh1, char.class, int.class); |
twisti@2351 | 337 | char a = (char) mh1.invokeExact((char) x); |
twisti@2351 | 338 | char b = (char) mh2.invokeExact(x); |
twisti@2351 | 339 | check(x, a, b); |
twisti@2256 | 340 | } |
twisti@2256 | 341 | |
twisti@2256 | 342 | // short |
twisti@2256 | 343 | { |
twisti@2256 | 344 | MethodHandle mh1 = getmh1( short.class, short.class); |
twisti@2256 | 345 | MethodHandle mh2 = getmh2(mh1, short.class, int.class); |
twisti@2351 | 346 | short a = (short) mh1.invokeExact((short) x); |
twisti@2351 | 347 | short b = (short) mh2.invokeExact(x); |
twisti@2256 | 348 | assert a == b : a + " != " + b; |
twisti@2351 | 349 | check(x, a, b); |
twisti@2256 | 350 | } |
twisti@2256 | 351 | |
twisti@2256 | 352 | // int |
twisti@2256 | 353 | { |
twisti@2256 | 354 | MethodHandle mh1 = getmh1( int.class, int.class); |
twisti@2256 | 355 | MethodHandle mh2 = getmh2(mh1, int.class, int.class); |
twisti@2351 | 356 | int a = (int) mh1.invokeExact((int) x); |
twisti@2351 | 357 | int b = (int) mh2.invokeExact(x); |
twisti@2351 | 358 | check(x, a, b); |
twisti@2256 | 359 | } |
twisti@2256 | 360 | } |
twisti@2256 | 361 | |
twisti@2256 | 362 | // test adapter_opt_l2i |
twisti@2256 | 363 | static void testlong() throws Throwable { |
twisti@2256 | 364 | long[] a = new long[] { |
twisti@2256 | 365 | Long.MIN_VALUE, |
twisti@2256 | 366 | Long.MIN_VALUE + 1, |
twisti@2256 | 367 | -0x000000000FFFFFFFL, |
twisti@2256 | 368 | -0x0000000000FFFFFFL, |
twisti@2256 | 369 | -0x00000000000FFFFFL, |
twisti@2256 | 370 | -0x000000000000FFFFL, |
twisti@2256 | 371 | -0x0000000000000FFFL, |
twisti@2256 | 372 | -0x00000000000000FFL, |
twisti@2256 | 373 | -0x000000000000000FL, |
twisti@2256 | 374 | -1L, |
twisti@2256 | 375 | 0L, |
twisti@2256 | 376 | 1L, |
twisti@2256 | 377 | 0x000000000000000FL, |
twisti@2256 | 378 | 0x00000000000000FFL, |
twisti@2256 | 379 | 0x0000000000000FFFL, |
twisti@2256 | 380 | 0x0000000000000FFFL, |
twisti@2256 | 381 | 0x000000000000FFFFL, |
twisti@2256 | 382 | 0x00000000000FFFFFL, |
twisti@2256 | 383 | 0x0000000000FFFFFFL, |
twisti@2256 | 384 | 0x000000000FFFFFFFL, |
twisti@2256 | 385 | Long.MAX_VALUE - 1, |
twisti@2256 | 386 | Long.MAX_VALUE |
twisti@2256 | 387 | }; |
twisti@2256 | 388 | for (int i = 0; i < a.length; i++) { |
twisti@2256 | 389 | dolong(a[i]); |
twisti@2256 | 390 | } |
twisti@2256 | 391 | } |
twisti@2256 | 392 | static void dolong(long x) throws Throwable { |
twisti@2256 | 393 | if (DEBUG) System.out.println("long=" + x); |
twisti@2256 | 394 | |
twisti@2256 | 395 | // boolean |
twisti@2256 | 396 | { |
twisti@2256 | 397 | MethodHandle mh1 = getmh1( boolean.class, boolean.class); |
twisti@2256 | 398 | MethodHandle mh2 = getmh2(mh1, boolean.class, long.class); |
twisti@2351 | 399 | boolean a = (boolean) mh1.invokeExact((x & 1L) == 1L); |
twisti@2351 | 400 | boolean b = (boolean) mh2.invokeExact(x); |
twisti@2351 | 401 | check(x, a, b); |
twisti@2256 | 402 | } |
twisti@2256 | 403 | |
twisti@2256 | 404 | // byte |
twisti@2256 | 405 | { |
twisti@2256 | 406 | MethodHandle mh1 = getmh1( byte.class, byte.class); |
twisti@2256 | 407 | MethodHandle mh2 = getmh2(mh1, byte.class, long.class); |
twisti@2351 | 408 | byte a = (byte) mh1.invokeExact((byte) x); |
twisti@2351 | 409 | byte b = (byte) mh2.invokeExact(x); |
twisti@2351 | 410 | check(x, a, b); |
twisti@2256 | 411 | } |
twisti@2256 | 412 | |
twisti@2256 | 413 | // char |
twisti@2256 | 414 | { |
twisti@2256 | 415 | MethodHandle mh1 = getmh1( char.class, char.class); |
twisti@2256 | 416 | MethodHandle mh2 = getmh2(mh1, char.class, long.class); |
twisti@2351 | 417 | char a = (char) mh1.invokeExact((char) x); |
twisti@2351 | 418 | char b = (char) mh2.invokeExact(x); |
twisti@2351 | 419 | check(x, a, b); |
twisti@2256 | 420 | } |
twisti@2256 | 421 | |
twisti@2256 | 422 | // short |
twisti@2256 | 423 | { |
twisti@2256 | 424 | MethodHandle mh1 = getmh1( short.class, short.class); |
twisti@2256 | 425 | MethodHandle mh2 = getmh2(mh1, short.class, long.class); |
twisti@2351 | 426 | short a = (short) mh1.invokeExact((short) x); |
twisti@2351 | 427 | short b = (short) mh2.invokeExact(x); |
twisti@2351 | 428 | check(x, a, b); |
twisti@2256 | 429 | } |
twisti@2256 | 430 | |
twisti@2256 | 431 | // int |
twisti@2256 | 432 | { |
twisti@2256 | 433 | MethodHandle mh1 = getmh1( int.class, int.class); |
twisti@2256 | 434 | MethodHandle mh2 = getmh2(mh1, int.class, long.class); |
twisti@2351 | 435 | int a = (int) mh1.invokeExact((int) x); |
twisti@2351 | 436 | int b = (int) mh2.invokeExact(x); |
twisti@2351 | 437 | check(x, a, b); |
twisti@2256 | 438 | } |
twisti@2351 | 439 | } |
twisti@2256 | 440 | |
twisti@2351 | 441 | static void check(boolean x, boolean e, boolean a) { p(z2h(x), z2h(e), z2h(a)); assert e == a : z2h(x) + ": " + z2h(e) + " != " + z2h(a); } |
twisti@2351 | 442 | static void check(boolean x, byte e, byte a) { p(z2h(x), i2h(e), i2h(a)); assert e == a : z2h(x) + ": " + i2h(e) + " != " + i2h(a); } |
twisti@2351 | 443 | static void check(boolean x, int e, int a) { p(z2h(x), i2h(e), i2h(a)); assert e == a : z2h(x) + ": " + i2h(e) + " != " + i2h(a); } |
twisti@2351 | 444 | |
twisti@2351 | 445 | static void check(int x, boolean e, boolean a) { p(i2h(x), z2h(e), z2h(a)); assert e == a : i2h(x) + ": " + z2h(e) + " != " + z2h(a); } |
twisti@2351 | 446 | static void check(int x, byte e, byte a) { p(i2h(x), i2h(e), i2h(a)); assert e == a : i2h(x) + ": " + i2h(e) + " != " + i2h(a); } |
twisti@2351 | 447 | static void check(int x, int e, int a) { p(i2h(x), i2h(e), i2h(a)); assert e == a : i2h(x) + ": " + i2h(e) + " != " + i2h(a); } |
twisti@2351 | 448 | |
twisti@2351 | 449 | static void check(long x, boolean e, boolean a) { p(l2h(x), z2h(e), z2h(a)); assert e == a : l2h(x) + ": " + z2h(e) + " != " + z2h(a); } |
twisti@2351 | 450 | static void check(long x, byte e, byte a) { p(l2h(x), i2h(e), i2h(a)); assert e == a : l2h(x) + ": " + i2h(e) + " != " + i2h(a); } |
twisti@2351 | 451 | static void check(long x, int e, int a) { p(l2h(x), i2h(e), i2h(a)); assert e == a : l2h(x) + ": " + i2h(e) + " != " + i2h(a); } |
twisti@2351 | 452 | |
twisti@2351 | 453 | static void p(String x, String e, String a) { if (DEBUG) System.out.println(x + ": expected: " + e + ", actual: " + a); } |
twisti@2351 | 454 | |
twisti@2351 | 455 | static String z2h(boolean x) { return x ? "1" : "0"; } |
twisti@2351 | 456 | static String i2h(int x) { return Integer.toHexString(x); } |
twisti@2351 | 457 | static String l2h(long x) { return Long.toHexString(x); } |
twisti@2256 | 458 | |
twisti@2256 | 459 | // to int |
twisti@2256 | 460 | public static boolean foo(boolean i) { return i; } |
twisti@2256 | 461 | public static byte foo(byte i) { return i; } |
twisti@2256 | 462 | public static char foo(char i) { return i; } |
twisti@2256 | 463 | public static short foo(short i) { return i; } |
twisti@2256 | 464 | public static int foo(int i) { return i; } |
twisti@2256 | 465 | } |