Thu, 24 Mar 2011 23:04:40 -0700
Merge
test/compiler/6987555/Test6987555.java | file | annotate | diff | comparison | revisions | |
test/compiler/6991596/Test6991596.java | file | annotate | diff | comparison | revisions |
1.1 --- a/test/compiler/6987555/Test6987555.java Thu Mar 24 02:11:50 2011 -0700 1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 @@ -1,177 +0,0 @@ 1.4 -/* 1.5 - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 1.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 - * 1.8 - * This code is free software; you can redistribute it and/or modify it 1.9 - * under the terms of the GNU General Public License version 2 only, as 1.10 - * published by the Free Software Foundation. 1.11 - * 1.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 - * version 2 for more details (a copy is included in the LICENSE file that 1.16 - * accompanied this code). 1.17 - * 1.18 - * You should have received a copy of the GNU General Public License version 1.19 - * 2 along with this work; if not, write to the Free Software Foundation, 1.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 - * 1.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 - * or visit www.oracle.com if you need additional information or have any 1.24 - * questions. 1.25 - * 1.26 - */ 1.27 - 1.28 -/** 1.29 - * @test 1.30 - * @bug 6987555 1.31 - * @summary JSR 292 unboxing to a boolean value fails on big-endian SPARC 1.32 - * 1.33 - * @run main/othervm -Xint -ea -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles -XX:+EnableInvokeDynamic -XX:+UnlockDiagnosticVMOptions -XX:+VerifyMethodHandles Test6987555 1.34 - */ 1.35 - 1.36 -import java.dyn.*; 1.37 - 1.38 -public class Test6987555 { 1.39 - private static final Class CLASS = Test6987555.class; 1.40 - private static final String NAME = "foo"; 1.41 - private static final boolean DEBUG = false; 1.42 - 1.43 - public static void main(String[] args) throws Throwable { 1.44 - testboolean(); 1.45 - testbyte(); 1.46 - testchar(); 1.47 - testshort(); 1.48 - testint(); 1.49 - } 1.50 - 1.51 - // boolean 1.52 - static void testboolean() throws Throwable { 1.53 - doboolean(false); 1.54 - doboolean(true); 1.55 - } 1.56 - static void doboolean(boolean x) throws Throwable { 1.57 - if (DEBUG) System.out.println("boolean=" + x); 1.58 - MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(boolean.class, boolean.class)); 1.59 - MethodHandle mh2 = mh1.asType(MethodType.methodType(boolean.class, Boolean.class)); 1.60 - boolean a = (boolean) mh1.invokeExact(x); 1.61 - boolean b = (boolean) mh2.invokeExact(Boolean.valueOf(x)); 1.62 - assert a == b : a + " != " + b; 1.63 - } 1.64 - 1.65 - // byte 1.66 - static void testbyte() throws Throwable { 1.67 - byte[] a = new byte[] { 1.68 - Byte.MIN_VALUE, 1.69 - Byte.MIN_VALUE + 1, 1.70 - -0x0F, 1.71 - -1, 1.72 - 0, 1.73 - 1, 1.74 - 0x0F, 1.75 - Byte.MAX_VALUE - 1, 1.76 - Byte.MAX_VALUE 1.77 - }; 1.78 - for (int i = 0; i < a.length; i++) { 1.79 - dobyte(a[i]); 1.80 - } 1.81 - } 1.82 - static void dobyte(byte x) throws Throwable { 1.83 - if (DEBUG) System.out.println("byte=" + x); 1.84 - MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(byte.class, byte.class)); 1.85 - MethodHandle mh2 = mh1.asType(MethodType.methodType(byte.class, Byte.class)); 1.86 - byte a = (byte) mh1.invokeExact(x); 1.87 - byte b = (byte) mh2.invokeExact(Byte.valueOf(x)); 1.88 - assert a == b : a + " != " + b; 1.89 - } 1.90 - 1.91 - // char 1.92 - static void testchar() throws Throwable { 1.93 - char[] a = new char[] { 1.94 - Character.MIN_VALUE, 1.95 - Character.MIN_VALUE + 1, 1.96 - 0x000F, 1.97 - 0x00FF, 1.98 - 0x0FFF, 1.99 - Character.MAX_VALUE - 1, 1.100 - Character.MAX_VALUE 1.101 - }; 1.102 - for (int i = 0; i < a.length; i++) { 1.103 - dochar(a[i]); 1.104 - } 1.105 - } 1.106 - static void dochar(char x) throws Throwable { 1.107 - if (DEBUG) System.out.println("char=" + x); 1.108 - MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(char.class, char.class)); 1.109 - MethodHandle mh2 = mh1.asType(MethodType.methodType(char.class, Character.class)); 1.110 - char a = (char) mh1.invokeExact(x); 1.111 - char b = (char) mh2.invokeExact(Character.valueOf(x)); 1.112 - assert a == b : a + " != " + b; 1.113 - } 1.114 - 1.115 - // short 1.116 - static void testshort() throws Throwable { 1.117 - short[] a = new short[] { 1.118 - Short.MIN_VALUE, 1.119 - Short.MIN_VALUE + 1, 1.120 - -0x0FFF, 1.121 - -0x00FF, 1.122 - -0x000F, 1.123 - -1, 1.124 - 0, 1.125 - 1, 1.126 - 0x000F, 1.127 - 0x00FF, 1.128 - 0x0FFF, 1.129 - Short.MAX_VALUE - 1, 1.130 - Short.MAX_VALUE 1.131 - }; 1.132 - for (int i = 0; i < a.length; i++) { 1.133 - doshort(a[i]); 1.134 - } 1.135 - } 1.136 - static void doshort(short x) throws Throwable { 1.137 - if (DEBUG) System.out.println("short=" + x); 1.138 - MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(short.class, short.class)); 1.139 - MethodHandle mh2 = mh1.asType(MethodType.methodType(short.class, Short.class)); 1.140 - short a = (short) mh1.invokeExact(x); 1.141 - short b = (short) mh2.invokeExact(Short.valueOf(x)); 1.142 - assert a == b : a + " != " + b; 1.143 - } 1.144 - 1.145 - // int 1.146 - static void testint() throws Throwable { 1.147 - int[] a = new int[] { 1.148 - Integer.MIN_VALUE, 1.149 - Integer.MIN_VALUE + 1, 1.150 - -0x00000FFF, 1.151 - -0x000000FF, 1.152 - -0x0000000F, 1.153 - -1, 1.154 - 0, 1.155 - 1, 1.156 - 0x0000000F, 1.157 - 0x000000FF, 1.158 - 0x00000FFF, 1.159 - Integer.MAX_VALUE - 1, 1.160 - Integer.MAX_VALUE 1.161 - }; 1.162 - for (int i = 0; i < a.length; i++) { 1.163 - doint(a[i]); 1.164 - } 1.165 - } 1.166 - static void doint(int x) throws Throwable { 1.167 - if (DEBUG) System.out.println("int=" + x); 1.168 - MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(int.class, int.class)); 1.169 - MethodHandle mh2 = mh1.asType(MethodType.methodType(int.class, Integer.class)); 1.170 - int a = (int) mh1.invokeExact(x); 1.171 - int b = (int) mh2.invokeExact(Integer.valueOf(x)); 1.172 - assert a == b : a + " != " + b; 1.173 - } 1.174 - 1.175 - public static boolean foo(boolean i) { return i; } 1.176 - public static byte foo(byte i) { return i; } 1.177 - public static char foo(char i) { return i; } 1.178 - public static short foo(short i) { return i; } 1.179 - public static int foo(int i) { return i; } 1.180 -}
2.1 --- a/test/compiler/6991596/Test6991596.java Thu Mar 24 02:11:50 2011 -0700 2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 2.3 @@ -1,465 +0,0 @@ 2.4 -/* 2.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 2.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.7 - * 2.8 - * This code is free software; you can redistribute it and/or modify it 2.9 - * under the terms of the GNU General Public License version 2 only, as 2.10 - * published by the Free Software Foundation. 2.11 - * 2.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 2.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.15 - * version 2 for more details (a copy is included in the LICENSE file that 2.16 - * accompanied this code). 2.17 - * 2.18 - * You should have received a copy of the GNU General Public License version 2.19 - * 2 along with this work; if not, write to the Free Software Foundation, 2.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.21 - * 2.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2.23 - * or visit www.oracle.com if you need additional information or have any 2.24 - * questions. 2.25 - * 2.26 - */ 2.27 - 2.28 -/** 2.29 - * @test 2.30 - * @bug 6991596 2.31 - * @summary JSR 292 unimplemented adapter_opt_i2i and adapter_opt_l2i on SPARC 2.32 - * 2.33 - * @run main/othervm -ea -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles -XX:+EnableInvokeDynamic -XX:+UnlockDiagnosticVMOptions -XX:+VerifyMethodHandles Test6991596 2.34 - */ 2.35 - 2.36 -import java.dyn.*; 2.37 - 2.38 -public class Test6991596 { 2.39 - private static final Class CLASS = Test6991596.class; 2.40 - private static final String NAME = "foo"; 2.41 - private static final boolean DEBUG = System.getProperty("DEBUG", "false").equals("true"); 2.42 - 2.43 - public static void main(String[] args) throws Throwable { 2.44 - testboolean(); 2.45 - testbyte(); 2.46 - testchar(); 2.47 - testshort(); 2.48 - testint(); 2.49 - testlong(); 2.50 - } 2.51 - 2.52 - // Helpers to get various methods. 2.53 - static MethodHandle getmh1(Class ret, Class arg) throws NoAccessException { 2.54 - return MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(ret, arg)); 2.55 - } 2.56 - static MethodHandle getmh2(MethodHandle mh1, Class ret, Class arg) { 2.57 - return MethodHandles.convertArguments(mh1, MethodType.methodType(ret, arg)); 2.58 - } 2.59 - static MethodHandle getmh3(MethodHandle mh1, Class ret, Class arg) { 2.60 - return MethodHandles.convertArguments(mh1, MethodType.methodType(ret, arg)); 2.61 - } 2.62 - 2.63 - // test adapter_opt_i2i 2.64 - static void testboolean() throws Throwable { 2.65 - boolean[] a = new boolean[] { 2.66 - true, 2.67 - false 2.68 - }; 2.69 - for (int i = 0; i < a.length; i++) { 2.70 - doboolean(a[i]); 2.71 - } 2.72 - } 2.73 - static void doboolean(boolean x) throws Throwable { 2.74 - if (DEBUG) System.out.println("boolean=" + x); 2.75 - 2.76 - // boolean 2.77 - { 2.78 - MethodHandle mh1 = getmh1( boolean.class, boolean.class); 2.79 - MethodHandle mh2 = getmh2(mh1, boolean.class, boolean.class); 2.80 - // TODO add this for all cases when the bugs are fixed. 2.81 - //MethodHandle mh3 = getmh3(mh1, boolean.class, boolean.class); 2.82 - boolean a = (boolean) mh1.invokeExact((boolean) x); 2.83 - boolean b = (boolean) mh2.invokeExact(x); 2.84 - //boolean c = mh3.<boolean>invokeExact((boolean) x); 2.85 - check(x, a, b); 2.86 - //check(x, c, x); 2.87 - } 2.88 - 2.89 - // byte 2.90 - { 2.91 - MethodHandle mh1 = getmh1( byte.class, byte.class ); 2.92 - MethodHandle mh2 = getmh2(mh1, byte.class, boolean.class); 2.93 - byte a = (byte) mh1.invokeExact((byte) (x ? 1 : 0)); 2.94 - byte b = (byte) mh2.invokeExact(x); 2.95 - check(x, a, b); 2.96 - } 2.97 - 2.98 - // char 2.99 - { 2.100 - MethodHandle mh1 = getmh1( char.class, char.class); 2.101 - MethodHandle mh2 = getmh2(mh1, char.class, boolean.class); 2.102 - char a = (char) mh1.invokeExact((char) (x ? 1 : 0)); 2.103 - char b = (char) mh2.invokeExact(x); 2.104 - check(x, a, b); 2.105 - } 2.106 - 2.107 - // short 2.108 - { 2.109 - MethodHandle mh1 = getmh1( short.class, short.class); 2.110 - MethodHandle mh2 = getmh2(mh1, short.class, boolean.class); 2.111 - short a = (short) mh1.invokeExact((short) (x ? 1 : 0)); 2.112 - short b = (short) mh2.invokeExact(x); 2.113 - check(x, a, b); 2.114 - } 2.115 - } 2.116 - 2.117 - static void testbyte() throws Throwable { 2.118 - byte[] a = new byte[] { 2.119 - Byte.MIN_VALUE, 2.120 - Byte.MIN_VALUE + 1, 2.121 - -0x0F, 2.122 - -1, 2.123 - 0, 2.124 - 1, 2.125 - 0x0F, 2.126 - Byte.MAX_VALUE - 1, 2.127 - Byte.MAX_VALUE 2.128 - }; 2.129 - for (int i = 0; i < a.length; i++) { 2.130 - dobyte(a[i]); 2.131 - } 2.132 - } 2.133 - static void dobyte(byte x) throws Throwable { 2.134 - if (DEBUG) System.out.println("byte=" + x); 2.135 - 2.136 - // boolean 2.137 - { 2.138 - MethodHandle mh1 = getmh1( boolean.class, boolean.class); 2.139 - MethodHandle mh2 = getmh2(mh1, boolean.class, byte.class); 2.140 - boolean a = (boolean) mh1.invokeExact((x & 1) == 1); 2.141 - boolean b = (boolean) mh2.invokeExact(x); 2.142 - check(x, a, b); 2.143 - } 2.144 - 2.145 - // byte 2.146 - { 2.147 - MethodHandle mh1 = getmh1( byte.class, byte.class); 2.148 - MethodHandle mh2 = getmh2(mh1, byte.class, byte.class); 2.149 - byte a = (byte) mh1.invokeExact((byte) x); 2.150 - byte b = (byte) mh2.invokeExact(x); 2.151 - check(x, a, b); 2.152 - } 2.153 - 2.154 - // char 2.155 - { 2.156 - MethodHandle mh1 = getmh1( char.class, char.class); 2.157 - MethodHandle mh2 = getmh2(mh1, char.class, byte.class); 2.158 - char a = (char) mh1.invokeExact((char) x); 2.159 - char b = (char) mh2.invokeExact(x); 2.160 - check(x, a, b); 2.161 - } 2.162 - 2.163 - // short 2.164 - { 2.165 - MethodHandle mh1 = getmh1( short.class, short.class); 2.166 - MethodHandle mh2 = getmh2(mh1, short.class, byte.class); 2.167 - short a = (short) mh1.invokeExact((short) x); 2.168 - short b = (short) mh2.invokeExact(x); 2.169 - check(x, a, b); 2.170 - } 2.171 - } 2.172 - 2.173 - static void testchar() throws Throwable { 2.174 - char[] a = new char[] { 2.175 - Character.MIN_VALUE, 2.176 - Character.MIN_VALUE + 1, 2.177 - 0x000F, 2.178 - 0x00FF, 2.179 - 0x0FFF, 2.180 - Character.MAX_VALUE - 1, 2.181 - Character.MAX_VALUE 2.182 - }; 2.183 - for (int i = 0; i < a.length; i++) { 2.184 - dochar(a[i]); 2.185 - } 2.186 - } 2.187 - static void dochar(char x) throws Throwable { 2.188 - if (DEBUG) System.out.println("char=" + x); 2.189 - 2.190 - // boolean 2.191 - { 2.192 - MethodHandle mh1 = getmh1( boolean.class, boolean.class); 2.193 - MethodHandle mh2 = getmh2(mh1, boolean.class, char.class); 2.194 - boolean a = (boolean) mh1.invokeExact((x & 1) == 1); 2.195 - boolean b = (boolean) mh2.invokeExact(x); 2.196 - check(x, a, b); 2.197 - } 2.198 - 2.199 - // byte 2.200 - { 2.201 - MethodHandle mh1 = getmh1( byte.class, byte.class); 2.202 - MethodHandle mh2 = getmh2(mh1, byte.class, char.class); 2.203 - byte a = (byte) mh1.invokeExact((byte) x); 2.204 - byte b = (byte) mh2.invokeExact(x); 2.205 - check(x, a, b); 2.206 - } 2.207 - 2.208 - // char 2.209 - { 2.210 - MethodHandle mh1 = getmh1( char.class, char.class); 2.211 - MethodHandle mh2 = getmh2(mh1, char.class, char.class); 2.212 - char a = (char) mh1.invokeExact((char) x); 2.213 - char b = (char) mh2.invokeExact(x); 2.214 - check(x, a, b); 2.215 - } 2.216 - 2.217 - // short 2.218 - { 2.219 - MethodHandle mh1 = getmh1( short.class, short.class); 2.220 - MethodHandle mh2 = getmh2(mh1, short.class, char.class); 2.221 - short a = (short) mh1.invokeExact((short) x); 2.222 - short b = (short) mh2.invokeExact(x); 2.223 - check(x, a, b); 2.224 - } 2.225 - } 2.226 - 2.227 - static void testshort() throws Throwable { 2.228 - short[] a = new short[] { 2.229 - Short.MIN_VALUE, 2.230 - Short.MIN_VALUE + 1, 2.231 - -0x0FFF, 2.232 - -0x00FF, 2.233 - -0x000F, 2.234 - -1, 2.235 - 0, 2.236 - 1, 2.237 - 0x000F, 2.238 - 0x00FF, 2.239 - 0x0FFF, 2.240 - Short.MAX_VALUE - 1, 2.241 - Short.MAX_VALUE 2.242 - }; 2.243 - for (int i = 0; i < a.length; i++) { 2.244 - doshort(a[i]); 2.245 - } 2.246 - } 2.247 - static void doshort(short x) throws Throwable { 2.248 - if (DEBUG) System.out.println("short=" + x); 2.249 - 2.250 - // boolean 2.251 - { 2.252 - MethodHandle mh1 = getmh1( boolean.class, boolean.class); 2.253 - MethodHandle mh2 = getmh2(mh1, boolean.class, short.class); 2.254 - boolean a = (boolean) mh1.invokeExact((x & 1) == 1); 2.255 - boolean b = (boolean) mh2.invokeExact(x); 2.256 - check(x, a, b); 2.257 - } 2.258 - 2.259 - // byte 2.260 - { 2.261 - MethodHandle mh1 = getmh1( byte.class, byte.class); 2.262 - MethodHandle mh2 = getmh2(mh1, byte.class, short.class); 2.263 - byte a = (byte) mh1.invokeExact((byte) x); 2.264 - byte b = (byte) mh2.invokeExact(x); 2.265 - check(x, a, b); 2.266 - } 2.267 - 2.268 - // char 2.269 - { 2.270 - MethodHandle mh1 = getmh1( char.class, char.class); 2.271 - MethodHandle mh2 = getmh2(mh1, char.class, short.class); 2.272 - char a = (char) mh1.invokeExact((char) x); 2.273 - char b = (char) mh2.invokeExact(x); 2.274 - check(x, a, b); 2.275 - } 2.276 - 2.277 - // short 2.278 - { 2.279 - MethodHandle mh1 = getmh1( short.class, short.class); 2.280 - MethodHandle mh2 = getmh2(mh1, short.class, short.class); 2.281 - short a = (short) mh1.invokeExact((short) x); 2.282 - short b = (short) mh2.invokeExact(x); 2.283 - check(x, a, b); 2.284 - } 2.285 - } 2.286 - 2.287 - static void testint() throws Throwable { 2.288 - int[] a = new int[] { 2.289 - Integer.MIN_VALUE, 2.290 - Integer.MIN_VALUE + 1, 2.291 - -0x0FFFFFFF, 2.292 - -0x00FFFFFF, 2.293 - -0x000FFFFF, 2.294 - -0x0000FFFF, 2.295 - -0x00000FFF, 2.296 - -0x000000FF, 2.297 - -0x0000000F, 2.298 - -1, 2.299 - 0, 2.300 - 1, 2.301 - 0x0000000F, 2.302 - 0x000000FF, 2.303 - 0x00000FFF, 2.304 - 0x0000FFFF, 2.305 - 0x000FFFFF, 2.306 - 0x00FFFFFF, 2.307 - 0x0FFFFFFF, 2.308 - Integer.MAX_VALUE - 1, 2.309 - Integer.MAX_VALUE 2.310 - }; 2.311 - for (int i = 0; i < a.length; i++) { 2.312 - doint(a[i]); 2.313 - } 2.314 - } 2.315 - static void doint(int x) throws Throwable { 2.316 - if (DEBUG) System.out.println("int=" + x); 2.317 - 2.318 - // boolean 2.319 - { 2.320 - MethodHandle mh1 = getmh1( boolean.class, boolean.class); 2.321 - MethodHandle mh2 = getmh2(mh1, boolean.class, int.class); 2.322 - boolean a = (boolean) mh1.invokeExact((x & 1) == 1); 2.323 - boolean b = (boolean) mh2.invokeExact(x); 2.324 - check(x, a, b); 2.325 - } 2.326 - 2.327 - // byte 2.328 - { 2.329 - MethodHandle mh1 = getmh1( byte.class, byte.class); 2.330 - MethodHandle mh2 = getmh2(mh1, byte.class, int.class); 2.331 - byte a = (byte) mh1.invokeExact((byte) x); 2.332 - byte b = (byte) mh2.invokeExact(x); 2.333 - check(x, a, b); 2.334 - } 2.335 - 2.336 - // char 2.337 - { 2.338 - MethodHandle mh1 = getmh1( char.class, char.class); 2.339 - MethodHandle mh2 = getmh2(mh1, char.class, int.class); 2.340 - char a = (char) mh1.invokeExact((char) x); 2.341 - char b = (char) mh2.invokeExact(x); 2.342 - check(x, a, b); 2.343 - } 2.344 - 2.345 - // short 2.346 - { 2.347 - MethodHandle mh1 = getmh1( short.class, short.class); 2.348 - MethodHandle mh2 = getmh2(mh1, short.class, int.class); 2.349 - short a = (short) mh1.invokeExact((short) x); 2.350 - short b = (short) mh2.invokeExact(x); 2.351 - assert a == b : a + " != " + b; 2.352 - check(x, a, b); 2.353 - } 2.354 - 2.355 - // int 2.356 - { 2.357 - MethodHandle mh1 = getmh1( int.class, int.class); 2.358 - MethodHandle mh2 = getmh2(mh1, int.class, int.class); 2.359 - int a = (int) mh1.invokeExact((int) x); 2.360 - int b = (int) mh2.invokeExact(x); 2.361 - check(x, a, b); 2.362 - } 2.363 - } 2.364 - 2.365 - // test adapter_opt_l2i 2.366 - static void testlong() throws Throwable { 2.367 - long[] a = new long[] { 2.368 - Long.MIN_VALUE, 2.369 - Long.MIN_VALUE + 1, 2.370 - -0x000000000FFFFFFFL, 2.371 - -0x0000000000FFFFFFL, 2.372 - -0x00000000000FFFFFL, 2.373 - -0x000000000000FFFFL, 2.374 - -0x0000000000000FFFL, 2.375 - -0x00000000000000FFL, 2.376 - -0x000000000000000FL, 2.377 - -1L, 2.378 - 0L, 2.379 - 1L, 2.380 - 0x000000000000000FL, 2.381 - 0x00000000000000FFL, 2.382 - 0x0000000000000FFFL, 2.383 - 0x0000000000000FFFL, 2.384 - 0x000000000000FFFFL, 2.385 - 0x00000000000FFFFFL, 2.386 - 0x0000000000FFFFFFL, 2.387 - 0x000000000FFFFFFFL, 2.388 - Long.MAX_VALUE - 1, 2.389 - Long.MAX_VALUE 2.390 - }; 2.391 - for (int i = 0; i < a.length; i++) { 2.392 - dolong(a[i]); 2.393 - } 2.394 - } 2.395 - static void dolong(long x) throws Throwable { 2.396 - if (DEBUG) System.out.println("long=" + x); 2.397 - 2.398 - // boolean 2.399 - { 2.400 - MethodHandle mh1 = getmh1( boolean.class, boolean.class); 2.401 - MethodHandle mh2 = getmh2(mh1, boolean.class, long.class); 2.402 - boolean a = (boolean) mh1.invokeExact((x & 1L) == 1L); 2.403 - boolean b = (boolean) mh2.invokeExact(x); 2.404 - check(x, a, b); 2.405 - } 2.406 - 2.407 - // byte 2.408 - { 2.409 - MethodHandle mh1 = getmh1( byte.class, byte.class); 2.410 - MethodHandle mh2 = getmh2(mh1, byte.class, long.class); 2.411 - byte a = (byte) mh1.invokeExact((byte) x); 2.412 - byte b = (byte) mh2.invokeExact(x); 2.413 - check(x, a, b); 2.414 - } 2.415 - 2.416 - // char 2.417 - { 2.418 - MethodHandle mh1 = getmh1( char.class, char.class); 2.419 - MethodHandle mh2 = getmh2(mh1, char.class, long.class); 2.420 - char a = (char) mh1.invokeExact((char) x); 2.421 - char b = (char) mh2.invokeExact(x); 2.422 - check(x, a, b); 2.423 - } 2.424 - 2.425 - // short 2.426 - { 2.427 - MethodHandle mh1 = getmh1( short.class, short.class); 2.428 - MethodHandle mh2 = getmh2(mh1, short.class, long.class); 2.429 - short a = (short) mh1.invokeExact((short) x); 2.430 - short b = (short) mh2.invokeExact(x); 2.431 - check(x, a, b); 2.432 - } 2.433 - 2.434 - // int 2.435 - { 2.436 - MethodHandle mh1 = getmh1( int.class, int.class); 2.437 - MethodHandle mh2 = getmh2(mh1, int.class, long.class); 2.438 - int a = (int) mh1.invokeExact((int) x); 2.439 - int b = (int) mh2.invokeExact(x); 2.440 - check(x, a, b); 2.441 - } 2.442 - } 2.443 - 2.444 - 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); } 2.445 - 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); } 2.446 - 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); } 2.447 - 2.448 - 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); } 2.449 - 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); } 2.450 - 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); } 2.451 - 2.452 - 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); } 2.453 - 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); } 2.454 - 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); } 2.455 - 2.456 - static void p(String x, String e, String a) { if (DEBUG) System.out.println(x + ": expected: " + e + ", actual: " + a); } 2.457 - 2.458 - static String z2h(boolean x) { return x ? "1" : "0"; } 2.459 - static String i2h(int x) { return Integer.toHexString(x); } 2.460 - static String l2h(long x) { return Long.toHexString(x); } 2.461 - 2.462 - // to int 2.463 - public static boolean foo(boolean i) { return i; } 2.464 - public static byte foo(byte i) { return i; } 2.465 - public static char foo(char i) { return i; } 2.466 - public static short foo(short i) { return i; } 2.467 - public static int foo(int i) { return i; } 2.468 -}