Duplicate :
|
|
Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
The following code prints invalid value in assertEquals() on solaris-sparc with -Xcomp option: public class T { static void assertEquals(Object exp, Object act) { System.out.println(exp + " vs " + act); } static MethodHandle asList; static void test() { MethodHandle makeEmptyList = MethodHandles.constant(List.class, Arrays.asList()); MethodHandle asList = lookup().findStatic(Arrays.class, "asList", methodType(List.class, Object[].class)); T.asList = asList; MethodHandle collectingTypeHandler = lookup() .findStatic(lookup().lookupClass(), "collectingTypeHandler", methodType(MethodHandle.class, MethodHandle.class, MethodType.class)); MethodHandle makeAnyList = makeEmptyList.withTypeHandler(collectingTypeHandler); assertEquals("TEST>[two, too]<TEST", makeAnyList.invokeGeneric("two", "too").toString()); } static MethodHandle collectingTypeHandler(MethodHandle base, MethodType newType) { return asList.asCollector(Object[].class, newType.parameterCount()).asType(newType); } } With -Xcomp, it prints: (String,String)Object vs [two, too] With -Xint it prints: TEST>[two, too]<TEST vs [two, too]
|