RFR: JDK-8245432: Lookup::defineHiddenClass should throw UnsupportedClassVersionError if the given bytes are of an unsupported major or minor version

Alan Bateman Alan.Bateman at oracle.com
Thu May 28 13:55:33 UTC 2020


On 28/05/2020 05:13, Mandy Chung wrote:
> Updated webrev:
> http://cr.openjdk.java.net/~mchung/jdk15/webrevs/8245432/webrev.01/
>
> I modify this patch to check the class file version and throws CFE if 
> unsupported before creating ClassReader.  This also fixes JDK-8245061 
> that it reads the value of `this_class` as a constant (as ASM will 
> throw an exception if it's not a constant) and also ensures that 
> `this_class` is a CONSTANT_Class_info by checking the descriptor 
> string from Type.
I don't want to complicate this further but the --enable-preview 
handling in the VM doesn't seem to expose an internal property that 
allows code in the libraries know if preview feature are enabled or not. 
I was assuming that isSupportedClassFileVersion would need to check that.

Will readUnsignedShort throw AIOBE if the offset is beyond the length? 
Also are you sure about "& 0xCAFEBABE", I assumed it would just check 
the magic number is equal to that.

-Alan.


More information about the core-libs-dev mailing list