Question about MethodHandles#explicitCastArgument
John Rose
john.r.rose at oracle.com
Thu Nov 15 19:09:00 PST 2012
On Nov 15, 2012, at 3:32 PM, John Rose wrote:
> It can be right, but only if the actual argument is a null reference. If it is a non-null Byte, it must unbox to a byte and then widen to a float.
Well, actually, in this case, the NPE should not happen either.
Nulls are explicitly cast (though not merely "converted") to zeroes. (The theory here is that an uninitialized Object reference can be usefully reinterpreted as an uninitialized primitive value. The zero of a type is exactly the values of an uninitialized field or array element of that type.)
Here's the spec.:
> f <em>T0</em> is a reference and <em>T1</em> a primitive,
> and if the reference is null at runtime, a zero value is introduced.
So, explictCastArguments should not produce a MH which can throw NPE.
CCE is still possible, e.g., if a String is cast to a File or a float, or vice versa.
— John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/mlvm-dev/attachments/20121115/d802cfba/attachment.html
More information about the mlvm-dev
mailing list