提交 4286fcb0 编写于 作者: V vlivanov

8066746: MHs.explicitCastArguments does incorrect type checks for VarargsCollector

Reviewed-by: jrose, psandoz
上级 54a226fd
...@@ -2029,7 +2029,7 @@ return invoker; ...@@ -2029,7 +2029,7 @@ return invoker;
MethodType oldType = target.type(); MethodType oldType = target.type();
if (oldType == newType) return target; if (oldType == newType) return target;
if (oldType.explicitCastEquivalentToAsType(newType)) { if (oldType.explicitCastEquivalentToAsType(newType)) {
return target.asType(newType); return target.asFixedArity().asType(newType);
} }
return MethodHandleImpl.makePairwiseConvert(target, newType, false); return MethodHandleImpl.makePairwiseConvert(target, newType, false);
} }
......
...@@ -32,15 +32,30 @@ import sun.invoke.util.Wrapper; ...@@ -32,15 +32,30 @@ import sun.invoke.util.Wrapper;
*/ */
public class ExplicitCastArgumentsTest { public class ExplicitCastArgumentsTest {
private static final boolean VERBOSE = Boolean.getBoolean("verbose"); private static final boolean VERBOSE = Boolean.getBoolean("verbose");
private static final Class<?> THIS_CLASS = ExplicitCastArgumentsTest.class;
public static void main(String[] args) throws Throwable { public static void main(String[] args) throws Throwable {
testVarargsCollector();
testRef2Prim();
System.out.println("TEST PASSED");
}
public static String[] f(String... args) { return args; }
public static void testVarargsCollector() throws Throwable {
MethodType mt = MethodType.methodType(String[].class, String[].class);
MethodHandle mh = MethodHandles.publicLookup().findStatic(THIS_CLASS, "f", mt);
mh = MethodHandles.explicitCastArguments(mh, MethodType.methodType(Object.class, Object.class));
mh.invokeWithArguments((Object)(new String[] {"str1", "str2"}));
}
public static void testRef2Prim() throws Throwable {
for (Wrapper from : Wrapper.values()) { for (Wrapper from : Wrapper.values()) {
for (Wrapper to : Wrapper.values()) { for (Wrapper to : Wrapper.values()) {
if (from == Wrapper.VOID || to == Wrapper.VOID) continue; if (from == Wrapper.VOID || to == Wrapper.VOID) continue;
testRef2Prim (from, to); testRef2Prim(from, to);
} }
} }
System.out.println("TEST PASSED");
} }
public static void testRef2Prim(Wrapper from, Wrapper to) throws Throwable { public static void testRef2Prim(Wrapper from, Wrapper to) throws Throwable {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册