Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayIndexOutOfBoundsException in Parser due to static init block #3524

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

mpalat
Copy link
Contributor

@mpalat mpalat commented Jan 6, 2025

issue #3506

What it does

The static initializer block initializations were wrongly interpreted as field declarations of the record which resulted in removing intPtr entries - additional entries than required. This resulted in wrong integer values for dimensions - as an example the source position integer was written as dimensions though the dimension was zero - and subsequent looping through the dimensions resulted in AIOOBE. The root cause was identified as the erroneous interpretation of the initializations with var declarations as Field Declarations of Records. This is corrected in the PR.

The check is being done by checking whether the nesting method level is the same as that of the record - based on the fact that the static initializer block will increment the nesting level. If a declaration is inside this static initializer block, the values would be differnt at the point of testing. Thus the fix.

How to test

A new test has been added which captures this by using a local record with a static field. Though not allowed and this has resulted in a negative test case, the fix is captured/covered by this test case - removal of the fix would result in the AIOOBE being thrown with this test case.

Author checklist

@mpalat mpalat self-assigned this Jan 6, 2025
@mpalat mpalat merged commit ee64a16 into eclipse-jdt:master Jan 7, 2025
10 checks passed
@mpalat mpalat deleted the issue-3506 branch January 7, 2025 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant