/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
/**
* @test
* @bug 6987555
* @summary JSR 292 unboxing to a boolean value fails on big-endian SPARC
*
*/
public class Test6987555 {
private static final boolean DEBUG = false;
testboolean();
testbyte();
testchar();
testshort();
testint();
}
// boolean
doboolean(false);
doboolean(true);
}
MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(boolean.class, boolean.class));
boolean a = (boolean) mh1.invokeExact(x);
assert a == b : a + " != " + b;
}
// byte
byte[] a = new byte[] {
-0x0F,
-1,
0,
1,
0x0F,
};
for (int i = 0; i < a.length; i++) {
dobyte(a[i]);
}
}
MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(byte.class, byte.class));
byte a = (byte) mh1.invokeExact(x);
assert a == b : a + " != " + b;
}
// char
char[] a = new char[] {
0x000F,
0x00FF,
0x0FFF,
};
for (int i = 0; i < a.length; i++) {
dochar(a[i]);
}
}
MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(char.class, char.class));
char a = (char) mh1.invokeExact(x);
assert a == b : a + " != " + b;
}
// short
short[] a = new short[] {
-0x0FFF,
-0x00FF,
-0x000F,
-1,
0,
1,
0x000F,
0x00FF,
0x0FFF,
};
for (int i = 0; i < a.length; i++) {
doshort(a[i]);
}
}
MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(short.class, short.class));
short a = (short) mh1.invokeExact(x);
assert a == b : a + " != " + b;
}
// int
int[] a = new int[] {
-0x00000FFF,
-0x000000FF,
-0x0000000F,
-1,
0,
1,
0x0000000F,
0x000000FF,
0x00000FFF,
};
for (int i = 0; i < a.length; i++) {
doint(a[i]);
}
}
MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(int.class, int.class));
int a = (int) mh1.invokeExact(x);
assert a == b : a + " != " + b;
}
public static boolean foo(boolean i) { return i; }
public static byte foo(byte i) { return i; }
public static char foo(char i) { return i; }
public static short foo(short i) { return i; }
public static int foo(int i) { return i; }
}