8143798: jck failures: api/java_lang/invoke/MethodHandle/index_MethodsTests[asSpreaderWMTE]: java.lang.VerifyError: Bad type on operand stack

Reviewed-by: vlivanov
This commit is contained in:
Michael Haupt 2015-11-25 09:23:07 +01:00
parent f5466fa917
commit 063afcee2f
2 changed files with 14 additions and 1 deletions

View File

@ -938,7 +938,7 @@ assertEquals("[A, B, C]", (String) caToString2.invokeExact('A', "BC".toCharArray
Class<?> arrayElement = arrayType.getComponentType();
MethodType mtype = type();
boolean match = true, fail = false;
for (int i = pos; i < arrayLength; i++) {
for (int i = pos; i < pos + arrayLength; i++) {
Class<?> ptype = mtype.parameterType(i);
if (ptype != arrayElement) {
match = false;

View File

@ -34,6 +34,7 @@ import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.invoke.MethodType;
import java.lang.invoke.WrongMethodTypeException;
import java.util.*;
import static java.lang.invoke.MethodType.methodType;
@ -412,6 +413,18 @@ public class T8139885 {
assertEquals(illegalPos.length, caught);
}
@Test
public static void testAsSpreaderIllegalMethodType() throws Throwable {
MethodHandle h = MethodHandles.dropArguments(MethodHandles.constant(String.class, ""), 0, int.class, int.class);
boolean caught = false;
try {
MethodHandle s = h.asSpreader(String[].class, 1);
} catch (WrongMethodTypeException wmte) {
caught = true;
}
assertTrue(caught);
}
@Test
public static void testAsCollector() throws Throwable {
MethodHandle collector = SpreadCollect.MH_forCollecting.asCollector(1, int[].class, 1);