RFR: 8333812: ClassFile.verify() can throw exceptions instead of returning VerifyErrors

Adam Sotona asotona at openjdk.org
Fri Jul 19 08:06:37 UTC 2024


On Thu, 18 Jul 2024 21:57:52 GMT, Chen Liang <liach at openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerifierImpl.java line 117:
>> 
>>> 115: 
>>> 116:     public static List<VerifyError> verify(ClassModel classModel, ClassHierarchyResolver classHierarchyResolver, Consumer<String> logger) {
>>> 117:         String clsName = classModel.thisClass().asInternalName();
>> 
>> This can still throw `ConstantPoolException` if this_class points to a non-Class entry. This entry is lazily read by `ClassReader`, so you can create a `ClassModel` for such a bad class.
>
> Alternatively, a malformed Class constant can point to a non-utf8, so the `asInternalName` can fail too.

Right, it will still throw if you pass a broken model to `ClassFile::verify(ClassModel)`.
I'll catch this top-level exception in both `ClassFile::verify` methods.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20241#discussion_r1683981268


More information about the core-libs-dev mailing list