On 28/05/2020 18:25, Mandy Chung wrote:
:
The runtime will ensure if --enable-preview is set if a class file
with minor is loaded. I will prefer to keep
VM::isSupportedClassFileVersion to validate the given major/minor
version. At runtime, it will fail when such class file is loaded if
preview is not enabled.
I'll add a comment to describe that.
Will readUnsignedShort throw AIOBE if the offset is beyond the length?
Good catch. I add the check to throw CFE.
+ private static int readUnsignedShort(byte[] bytes, int
offset) {
+ if (offset >= bytes.length) {
+ throw new ClassFormatError("Invalid ClassFile
structure");
+ }
+ return ((bytes[offset] & 0xFF) << 8) | (bytes[offset
+ 1] & 0xFF);
+ }
Also are you sure about "& 0xCAFEBABE", I assumed it would just check
the magic number is equal to that.
It should check ==. Fixed.
Thanks, this is okay with me.
-Alan.