Question about MethodHandles#explicitCastArgument
Jochen Theodorou
blackdrag at gmx.org
Thu Nov 15 23:13:23 PST 2012
Hi John,
Am 16.11.2012 04:09, schrieb John Rose:
> 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.
even if a null value would cause a NPE, I would expect that once the
handle is executed, not while I cal explicitCastArguments.
> 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.
Well, again... it does not, it cannot, since the call of
explictCastArguments itself causes the NPE. That means I found a bug? ;)
I am using build 1.7.0_09-b05 on Ubuntu 64bit.
Currently I work around this by leaving primitive2primitive conversions
as well as boxing and unboxing and anything a bytecode cast could do to
explictCastArguments. But when it comes to chain primitive conversions
and (un)boxing, I am doing that myself... even if the documentation says
it is supposed to work.
bye Jochen
--
Jochen "blackdrag" Theodorou - Groovy Project Tech Lead
blog: http://blackdragsview.blogspot.com/
german groovy discussion newsgroup: de.comp.lang.misc
For Groovy programming sources visit http://groovy-lang.org
More information about the mlvm-dev
mailing list