Print this page
Split |
Close |
Expand all |
Collapse all |
--- old/test/compiler/6987555/Test6987555.java
+++ new/test/compiler/6987555/Test6987555.java
1 1 /*
2 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 20 * or visit www.oracle.com if you need additional information or have any
21 21 * questions.
22 22 *
23 23 */
24 24
25 25 /**
26 26 * @test
27 27 * @bug 6987555
28 28 * @summary JSR 292 unboxing to a boolean value fails on big-endian SPARC
29 29 *
30 30 * @run main/othervm -Xint -ea -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles -XX:+EnableInvokeDynamic -XX:+UnlockDiagnosticVMOptions -XX:+VerifyMethodHandles Test6987555
31 31 */
32 32
33 33 import java.dyn.*;
34 34
35 35 public class Test6987555 {
36 36 private static final Class CLASS = Test6987555.class;
37 37 private static final String NAME = "foo";
38 38 private static final boolean DEBUG = false;
39 39
40 40 public static void main(String[] args) throws Throwable {
41 41 testboolean();
42 42 testbyte();
43 43 testchar();
44 44 testshort();
45 45 testint();
46 46 }
↓ open down ↓ |
34 lines elided |
↑ open up ↑ |
47 47
48 48 // boolean
49 49 static void testboolean() throws Throwable {
50 50 doboolean(false);
51 51 doboolean(true);
52 52 }
53 53 static void doboolean(boolean x) throws Throwable {
54 54 if (DEBUG) System.out.println("boolean=" + x);
55 55 MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(boolean.class, boolean.class));
56 56 MethodHandle mh2 = mh1.asType(MethodType.methodType(boolean.class, Boolean.class));
57 - boolean a = mh1.<boolean>invokeExact(x);
58 - boolean b = mh2.<boolean>invokeExact(Boolean.valueOf(x));
57 + boolean a = (boolean) mh1.invokeExact(x);
58 + boolean b = (boolean) mh2.invokeExact(Boolean.valueOf(x));
59 59 assert a == b : a + " != " + b;
60 60 }
61 61
62 62 // byte
63 63 static void testbyte() throws Throwable {
64 64 byte[] a = new byte[] {
65 65 Byte.MIN_VALUE,
66 66 Byte.MIN_VALUE + 1,
67 67 -0x0F,
68 68 -1,
69 69 0,
70 70 1,
71 71 0x0F,
72 72 Byte.MAX_VALUE - 1,
↓ open down ↓ |
4 lines elided |
↑ open up ↑ |
73 73 Byte.MAX_VALUE
74 74 };
75 75 for (int i = 0; i < a.length; i++) {
76 76 dobyte(a[i]);
77 77 }
78 78 }
79 79 static void dobyte(byte x) throws Throwable {
80 80 if (DEBUG) System.out.println("byte=" + x);
81 81 MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(byte.class, byte.class));
82 82 MethodHandle mh2 = mh1.asType(MethodType.methodType(byte.class, Byte.class));
83 - byte a = mh1.<byte>invokeExact(x);
84 - byte b = mh2.<byte>invokeExact(Byte.valueOf(x));
83 + byte a = (byte) mh1.invokeExact(x);
84 + byte b = (byte) mh2.invokeExact(Byte.valueOf(x));
85 85 assert a == b : a + " != " + b;
86 86 }
87 87
88 88 // char
89 89 static void testchar() throws Throwable {
90 90 char[] a = new char[] {
91 91 Character.MIN_VALUE,
92 92 Character.MIN_VALUE + 1,
93 93 0x000F,
94 94 0x00FF,
95 95 0x0FFF,
96 96 Character.MAX_VALUE - 1,
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
97 97 Character.MAX_VALUE
98 98 };
99 99 for (int i = 0; i < a.length; i++) {
100 100 dochar(a[i]);
101 101 }
102 102 }
103 103 static void dochar(char x) throws Throwable {
104 104 if (DEBUG) System.out.println("char=" + x);
105 105 MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(char.class, char.class));
106 106 MethodHandle mh2 = mh1.asType(MethodType.methodType(char.class, Character.class));
107 - char a = mh1.<char>invokeExact(x);
108 - char b = mh2.<char>invokeExact(Character.valueOf(x));
107 + char a = (char) mh1.invokeExact(x);
108 + char b = (char) mh2.invokeExact(Character.valueOf(x));
109 109 assert a == b : a + " != " + b;
110 110 }
111 111
112 112 // short
113 113 static void testshort() throws Throwable {
114 114 short[] a = new short[] {
115 115 Short.MIN_VALUE,
116 116 Short.MIN_VALUE + 1,
117 117 -0x0FFF,
118 118 -0x00FF,
119 119 -0x000F,
120 120 -1,
121 121 0,
122 122 1,
123 123 0x000F,
124 124 0x00FF,
125 125 0x0FFF,
126 126 Short.MAX_VALUE - 1,
↓ open down ↓ |
8 lines elided |
↑ open up ↑ |
127 127 Short.MAX_VALUE
128 128 };
129 129 for (int i = 0; i < a.length; i++) {
130 130 doshort(a[i]);
131 131 }
132 132 }
133 133 static void doshort(short x) throws Throwable {
134 134 if (DEBUG) System.out.println("short=" + x);
135 135 MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(short.class, short.class));
136 136 MethodHandle mh2 = mh1.asType(MethodType.methodType(short.class, Short.class));
137 - short a = mh1.<short>invokeExact(x);
138 - short b = mh2.<short>invokeExact(Short.valueOf(x));
137 + short a = (short) mh1.invokeExact(x);
138 + short b = (short) mh2.invokeExact(Short.valueOf(x));
139 139 assert a == b : a + " != " + b;
140 140 }
141 141
142 142 // int
143 143 static void testint() throws Throwable {
144 144 int[] a = new int[] {
145 145 Integer.MIN_VALUE,
146 146 Integer.MIN_VALUE + 1,
147 147 -0x00000FFF,
148 148 -0x000000FF,
149 149 -0x0000000F,
150 150 -1,
151 151 0,
152 152 1,
153 153 0x0000000F,
154 154 0x000000FF,
155 155 0x00000FFF,
156 156 Integer.MAX_VALUE - 1,
↓ open down ↓ |
8 lines elided |
↑ open up ↑ |
157 157 Integer.MAX_VALUE
158 158 };
159 159 for (int i = 0; i < a.length; i++) {
160 160 doint(a[i]);
161 161 }
162 162 }
163 163 static void doint(int x) throws Throwable {
164 164 if (DEBUG) System.out.println("int=" + x);
165 165 MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(int.class, int.class));
166 166 MethodHandle mh2 = mh1.asType(MethodType.methodType(int.class, Integer.class));
167 - int a = mh1.<int>invokeExact(x);
168 - int b = mh2.<int>invokeExact(Integer.valueOf(x));
167 + int a = (int) mh1.invokeExact(x);
168 + int b = (int) mh2.invokeExact(Integer.valueOf(x));
169 169 assert a == b : a + " != " + b;
170 170 }
171 171
172 172 public static boolean foo(boolean i) { return i; }
173 173 public static byte foo(byte i) { return i; }
174 174 public static char foo(char i) { return i; }
175 175 public static short foo(short i) { return i; }
176 176 public static int foo(int i) { return i; }
177 177 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX