RFR: 8320396: Class-File API ClassModel::verify should include checks from hotspot/share/classfile/classFileParser.cpp [v6]

Maurizio Cimadamore mcimadamore at openjdk.org
Wed May 15 09:48:17 UTC 2024


On Tue, 14 May 2024 11:42:19 GMT, Adam Sotona <asotona at openjdk.org> wrote:

>> ClassFile API `jdk.internal.classfile.verifier.VerifierImpl` performed only bytecode-level class verification.
>> This patch adds `jdk.internal.classfile.verifier.ParserVerifier` with additional class checks inspired by `hotspot/share/classfile/classFileParser.cpp`.
>> 
>> Also new `VerifierSelfTest::testParserVerifier` has been added.
>> 
>> Please review.
>> 
>> Thanks,
>> Adam
>
> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision:
> 
>   applied the suggested changes

src/java.base/share/classes/jdk/internal/classfile/impl/verifier/ParserVerifier.java line 205:

> 203:     private void verifyAttribute(AttributedElement ae, Attribute<?> a, List<VerifyError> errors) {
> 204:         int size = -1;
> 205:         switch (a) {

Maybe use a switch expression to set `size` where `default` yields -1?

src/java.base/share/classes/jdk/internal/classfile/impl/verifier/ParserVerifier.java line 306:

> 304:                 size = 1;
> 305:                 for (var ans : aa.parameterAnnotations()) {
> 306:                     size += annotationsSize(ans);

Shouldn't we call the new method here (passing `parameterAnnotations`) ?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16809#discussion_r1601317434
PR Review Comment: https://git.openjdk.org/jdk/pull/16809#discussion_r1601320492


More information about the compiler-dev mailing list