MethodHandle.invoke* should only work with source 1.7
Rémi Forax
forax at univ-mlv.fr
Thu Feb 10 03:46:37 PST 2011
On 02/10/2011 12:33 PM, Maurizio Cimadamore wrote:
> On 10/02/11 10:20, Rémi Forax wrote:
>> I've noticed that javac allows to use MethodHandle.invokeExact() or
>> MethodHandle.invokeGeneric if the source version is 1.6
>>
>> It's not a good idea because you can't use a real 1.6 javac to
>> compile these methods.
>>
>> Rémi
>>
>>
>>
> Well, yes and no. Javac allows such calls with -source 6 but won't
> apply any of the 292 magic - that is, the behavior you will get will
> be the same as if you compile the code with a real javac compiler -
> @PolymorphicSignature will be ignored and no extra bytecode info will
> be generated.
>
> Maurizio
The main problem is that when you will run it, with a 1.7 VM because
MethodHandle is only available with a 1.7 VM,
the VM will throw a WrongMethodTypeException because as you said the 292
magic will be ignored.
I think it's better for the users to don't compile instead of compiling
something which is inherently wrong.
Rémi
More information about the mlvm-dev
mailing list