MethodHandle.invoke* should only work with source 1.7
John Rose
john.r.rose at oracle.com
Thu Feb 10 15:03:36 PST 2011
On Feb 10, 2011, at 3:46 AM, Rémi Forax wrote:
> 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.
Try compiling mh.invokeExact using a 1.6 compiler against a 1.7 rt.jar. You should get a compile-time error, since the class file version numbers are wrong. The 1.6 compiler should refuse to load MethodHandle.class from rt.jar.
If you compile against a non-standard rt.jar, you might get the error you are observing, but that error won't affect 1.7 users. If it affects backport users, I suggest taking steps to put the java.dyn package jar in a special place where the 1.6 compiler is not going to see it, by default.
There are lots of variations on this theme of version mismatches. But the class file version number saves us in a lot of them.
-- John
More information about the mlvm-dev
mailing list