RFR: 8333812: ClassFile.verify() can throw exceptions instead of returning VerifyErrors [v3]
ExE Boss
duke at openjdk.org
Fri Jul 19 22:32:40 UTC 2024
On Fri, 19 Jul 2024 08:26:46 GMT, Adam Sotona <asotona at openjdk.org> wrote:
>> `ClassFile.verify()` should always return list of verification errors and never throw an exception, even for corrupted classes.
>> `BoundAttribute` initializations of `LocalVariableTable` and `LocalVariableTypeTable` attributes do not expect invalid possible locations and cause `ClassCastException`.
>>
>> This patch fixes `BoundAttribute` to throw `IllegalArgumentException` for invalid `LocalVariableTable` and `LocalVariableTypeTable` attributes locations. And makes `VerifierImpl` a bit more resilient to exceptions thrown from the verifier initialization.
>>
>> Relevant test is added.
>>
>> Please review.
>>
>> Thanks,
>> Adam
>
> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision:
>
> nit change
src/java.base/share/classes/jdk/internal/classfile/impl/ClassFileImpl.java line 138:
> 136: return VerifierImpl.verify(model, classHierarchyResolverOption().classHierarchyResolver(), null);
> 137: } catch (IllegalArgumentException verifierInitializationError) {
> 138: return List.of(new VerifyError(verifierInitializationError.getMessage()));
Note that the list returned by `VerifierImpl.verify(…)` is mutable, whereas `List.of(…)` is unmodifiable.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20241#discussion_r1685063956
More information about the core-libs-dev
mailing list