RFR: 8304837: Classfile API throws IOOBE for MethodParameters attribute without parameter names [v3]
Joe Darcy
darcy at openjdk.org
Fri Mar 24 21:10:31 UTC 2023
On Fri, 24 Mar 2023 06:42:30 GMT, Hannes Greule <duke at openjdk.org> wrote:
>> After merging master into https://github.com/openjdk/jdk/pull/9862, we encountered test failures (e.g., https://github.com/SirYwell/jdk/actions/runs/4500940829/jobs/7923018438#step:9:2541). The Classfile API tries to read from constant pool index 0 if a MethodParameters attribute has an entry without name.
>>
>> The fix is simply using `readUtf8EntryOrNull` instead of `readUtf8Entry`. The related code already correctly handles nullability.
>>
>> I didn't find an appropriate test class so I added a new one. Let me know if there's a better place or if the test can be improved somehow.
>>
>> As I don't have a JBS account, someone needs to create a bug report there for me. Thanks.
>
> Hannes Greule has updated the pull request incrementally with one additional commit since the last revision:
>
> Move and fix test comment
And just to double-check, the JVMS does allow the parameter name information to be missing even if the access flags are defined:
https://docs.oracle.com/javase/specs/jvms/se20/html/jvms-4.html#jvms-4.7.24
> name_index
>
> The value of the name_index item must either be zero or a valid index into the constant_pool table.
>
> If the value of the name_index item is zero, then this parameters element indicates a formal parameter with no name.
>
> If the value of the name_index item is nonzero, the constant_pool entry at that index must be a CONSTANT_Utf8_info structure representing a valid unqualified name denoting a formal parameter ([§4.2.2](https://docs.oracle.com/javase/specs/jvms/se20/html/jvms-4.html#jvms-4.2.2)).
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13167#issuecomment-1483407717
More information about the core-libs-dev
mailing list