[9] RFR (S) 8057656: Improve MethodType.isCastableTo() & MethodType.isConvertibleTo() checks
Paul Sandoz
paul.sandoz at oracle.com
Fri Sep 5 10:51:51 UTC 2014
On Sep 5, 2014, at 10:23 AM, Vladimir Ivanov <vladimir.x.ivanov at oracle.com> wrote:
> http://cr.openjdk.java.net/~vlivanov/8057656/webrev.00/
> https://bugs.openjdk.java.net/browse/JDK-8057656
>
854 if (!canConvert(returnType(), newType.returnType()))
855 return false;
856 Class<?>[] srcTypes = newType.ptypes;
857 Class<?>[] dstTypes = ptypes;
Are the src and dst the wrong way around?
srcTypes = ptypes
dstTypes = newType.ptypes
896 private static boolean canCast(Class<?> src, Class<?> dst) {
897 if (src.isPrimitive() && !dst.isPrimitive()) {
898 if (dst == Object.class || dst.isInterface()) return true;
How come if the src is primitive and the dst is an interface it returns true for any interface? I guess there are subtly different rules here for casting and conversion.
Paul.
> There are some corner cases which MT.isCastableTo() & MT.isConvertibleTo() don't treat right (e.g. int->String converstion of return type in MT.isCastableTo()).
>
> Testing: jdk/java/lang/invoke, jdk/java/util/streams, nashorn, octane w/ "-ea -esa" and COMPILE_THRESHOLD={0,30}.
>
> Reviewed-by: vlivanov, ?
> Contributed-by: john.r.rose at oracle.com
>
> Thanks!
>
>
> Best regards,
> Vladimir Ivanov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/mlvm-dev/attachments/20140905/9835f218/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.openjdk.java.net/pipermail/mlvm-dev/attachments/20140905/9835f218/signature.asc>
More information about the mlvm-dev
mailing list