/*
* 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
* @summary unit tests for value-type conversion utilities
* @ignore This test requires a special compilation environment to access sun.inovke.util. Run by hand.
* -DValueConversionsTest.MAX_ARITY=255 -DValueConversionsTest.START_ARITY=250
* test.sun.invoke.util.ValueConversionsTest
*/
// This might take a while and burn lots of metadata:
// @run junit/othervm -DValueConversionsTest.MAX_ARITY=255 -DValueConversionsTest.EXHAUSTIVE=true test.sun.invoke.util.ValueConversionsTest
/**
*
* @author jrose
*/
public class ValueConversionsTest {
@Test
testUnbox(false);
}
@Test
testUnbox(true);
}
//System.out.println("unbox");
//System.out.println(dst);
}
}
}
expectThrow = false; // everything (even VOID==null here) converts to OBJECT
try {
for (int n = -5; n < 10; n++) {
switch (src) {
}
if (doCast)
else
switch (dst) {
}
if (expectThrow) {
expResult = "(need an exception)";
}
}
} catch (RuntimeException ex) {
if (expectThrow) return;
System.out.println("Unexpected throw for (doCast,expectThrow,dst,src)="+Arrays.asList(doCast,expectThrow,dst,src));
throw ex;
}
}
@Test
//System.out.println("box");
//System.out.println(w);
for (int n = -5; n < 10; n++) {
switch (w) {
}
}
}
}
@Test
//System.out.println("cast");
//System.out.println("obj="+obj+" <: dst="+dst+(canCast ? " (OK)" : " (will fail)"));
try {
if (canCast)
else
} catch (ClassCastException ex) {
if (canCast)
throw ex;
}
}
}
}
@Test
//System.out.println("identity");
// compiler bug: ValueConversions.identity().invokeExact("bar");
}
@Test
//System.out.println("convert");
// next test value:
//System.out.println(Long.toHexString(tval)); // prints 3776 test patterns
if (tval == 0) {
//System.out.println("test value count = "+ctr); // 3776 = 8*59*8
break; // repeat
}
}
}
}
}
//System.out.println(src+" => "+dst);
else
for (;;) {
long n = tval;
switch (src) {
default: throw new AssertionError();
}
if (testSingleCase) break;
// next test value:
}
}
static long tweakSign(long x) {
// Assuming that x is mostly zeroes, make those zeroes follow bit #62 (just below the sign).
// This function is self-inverse.
final long MID_SIGN_BIT = 62;
return x ^ flip;
}
static long nextTestValue(long x) {
// Produce 64 bits with three component bitfields: [ high:3 | mid:58 | low:3 ].
// The high and low fields vary through all possible bit patterns.
// The middle field is either all zero or has a single bit set.
// For better coverage of the neighborhood of zero, an internal sign bit is xored downward also.
++ux;
} else {
ux &= ~LOW_BITS_MASK;
if (midBit == 0)
}
}
@Test
//System.out.println("varargsArray");
final int MIN = START_ARITY;
for (int i = 0; i < nargs; i++)
args[i] = "#"+i;
}
}
@Test
//System.out.println("varargsReferenceArray");
testTypedVarargsArray(Object[].class);
testTypedVarargsArray(String[].class);
testTypedVarargsArray(Number[].class);
}
@Test
//System.out.println("varargsPrimitiveArray");
testTypedVarargsArray(int[].class);
testTypedVarargsArray(long[].class);
testTypedVarargsArray(byte[].class);
testTypedVarargsArray(boolean[].class);
testTypedVarargsArray(short[].class);
testTypedVarargsArray(char[].class);
testTypedVarargsArray(float[].class);
testTypedVarargsArray(double[].class);
}
++nargs;
} else {
}
return nargs;
}
//System.out.println(arrayType.getSimpleName());
int MIN = START_ARITY;
int density = 3;
if (nargs != 0) {
}
vaType);
if (nargs <= 5) {
// invoke target as a spreader also:
@SuppressWarnings("cast")
// invoke the spreader on a generic Object[] array; check for error
try {
} catch (ClassCastException ex) {
}
}
if (nargs == 0) {
// invoke spreader on null arglist
}
}
}
if (elemType.isPrimitive())
for (int i = 0; i < len; i++) {
} else {
switch (elem) {
}
}
}
//System.out.println(elemType.getName()+Arrays.toString(args));
return args;
}
if (a == null) return "null";
if (elemType.isPrimitive()) {
}
}
}
@Test
//System.out.println("varargsList");
final int MIN = START_ARITY;
for (int i = 0; i < nargs; i++)
args[i] = "#"+i;
}
}
}