RFR: JDK-8245432: Lookup::defineHiddenClass should throw UnsupportedClassVersionError if the given bytes are of an unsupported major or minor version
David Holmes
david.holmes at oracle.com
Wed May 27 07:24:34 UTC 2020
Hi Mandy,
On 27/05/2020 7:46 am, Mandy Chung wrote:
> Lookup::defineHiddenClass currently throws IAE by ASM if the given bytes
> are of unsupported class file version. The implementation should catch
> and throw UnsupportedClassVersionError instead.
>
> webrev:
> http://cr.openjdk.java.net/~mchung/jdk15/webrevs/8245432/webrev.00/
What happened to the check:
if ((reader.getAccess() & Opcodes.ACC_MODULE) != 0) {
?
2036 if (msg.startsWith("Unsupported class file major
version")) {
Is that too strict - what if the issue is with the minor version? In
general having to parse the ASM exception seems fragile.
This code:
if (msg.startsWith("Unsupported class file major version")) {
UnsupportedClassVersionError ucve = new
UnsupportedClassVersionError(msg);
ucve.initCause(e);
throw ucve;
} else {
ClassFormatError cfe = new ClassFormatError();
cfe.initCause(e);
throw cfe;
}
could be simplified to:
ClassFormatError cfe;
if (msg.startsWith("Unsupported class file major version")) {
cfe = new UnsupportedClassVersionError(msg);
} else {
cfe = new ClassFormatError();
}
cfe.initCause(e);
throw cfe;
> This patch also includes a spec clarification of @throws IAE if the
> the bytes has ACC_MODULE flag set to fix JDK-8245596.
Until I saw what the code did the old versus new text did not seem like
a clarification. Might I suggest augmenting rather than replacing the
existing text:
@throws IllegalArgumentException if {@code bytes} is not a class or
interface (the ACC_MODULE flag is set in the value of the {@code
access_flags} item) or
Note:
1927 * in the value of the {@coode access_flags} item or
Typo: coode
Also should same change be made to defineHiddenClassWithClassData docs.
Thanks,
David
-----
> thanks
> Mandy
More information about the core-libs-dev
mailing list