Skip to content

Fix ArrayIndexOutOfBoundsException in processMethodAnnotations - #2553

Open
MonkeyMoon104 wants to merge 1 commit into
stefvanschie:masterfrom
MonkeyMoon104:fix/processMethodAnnotations-empty-params
Open

Fix ArrayIndexOutOfBoundsException in processMethodAnnotations#2553
MonkeyMoon104 wants to merge 1 commit into
stefvanschie:masterfrom
MonkeyMoon104:fix/processMethodAnnotations-empty-params

Conversation

@MonkeyMoon104

Copy link
Copy Markdown

Summary

  • Fix ArrayIndexOutOfBoundsException in Gui.processMethodAnnotations introduced in 0.12.1.
  • Zero-parameter methods on GUI subclasses (for example update() / copy()) were scanned and getParameterTypes()[0] was accessed unconditionally.
  • Only read the first parameter type when parameterCount > 0.

Test plan

  • new ChestGui(rows, title, plugin) no longer throws
  • Annotated zero-arg and one-arg click/drag/close handlers still work

ChestGui and other Gui subclasses declare zero-parameter methods such as
update() and copy(). processMethodAnnotations always read
getParameterTypes()[0] before checking parameterCount, so constructing any
ChestGui crashed with Index 0 out of bounds for length 0.

Only resolve the first parameter type when parameterCount is greater than
zero, matching the existing zero-arg annotation handler path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants