On Mon, 1 Aug 2022 13:30:21 GMT, Harold Seigel <hsei...@openjdk.org> wrote:

>> src/hotspot/share/prims/jvm.cpp line 4064:
>> 
>>> 4062:   assert(c->is_instance_klass(), "must be");
>>> 4063:   InstanceKlass* ik = InstanceKlass::cast(c);
>>> 4064:   return (ik->minor_version() << 16) | ik->major_version();
>> 
>> I'm curious why the format is minor:major rather than major:minor ?
>
> This was requested by @RogerRiggs 
> 
> Major high vs low bits requires either:
>   High bits:   val >>>16
>   Low bits:     val & 0xffff
> 
> Except for preview, the minor version is 0, so putting major version  in the 
> low bits allows trivial comparison (without masking); but may lead to bugs 
> due to carelessness.

Okay makes sense.

>> test/hotspot/jtreg/runtime/ClassFile/ClassFileVersionTest.java line 31:
>> 
>>> 29:  * @modules java.base/java.lang:open
>>> 30:  * @compile classFileVersions.jcod
>>> 31:  * @run main/othervm --enable-preview ClassFileVersionTest
>> 
>> What preview feature is being used here?
>
> No preview feature is being used but --enable-preview is needed here for the 
> JVM to accept a class with a minor version of 65535.

Ah I see.

-------------

PR: https://git.openjdk.org/jdk/pull/9688

Reply via email to