On 02/11/2011 01:01 AM, maurizio cimadamore wrote: > On 10/02/2011 23:03, John Rose wrote: >> 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. > Note also that if you use the JDK 7 compiler with -source 6 flag to > compile a class that contains MethodHandle, a warning will be emitted > (not related to MethodHandle though): > > warning: [options] bootstrap class path not set in conjunction with > -source 1.6 > 1 warning > > IMHO the above warning should be enough to justify the runtime > failure... if you follow the warning suggestion and fix bootclasspath > (to point to JDK 6's rt.jar) then the program won't compile anymore (as > java.dyn is not available in JDK 6).
A warning is not enough, in my opinion. Anyway, I wonder why hotspot works when it find a Methodhandle.invoke* in a 1.6 classfile. > Maurizio >> -- John Rémi _______________________________________________ mlvm-dev mailing list [email protected] http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev
