Skip to content

Conversation

@WeThink25
Copy link

Add null and empty check for targetClass methods

Add null and empty check for targetClass methods
@WeThink25
Copy link
Author

Add null and empty checks for targetClass methods to prevent IndexOutOfBoundsException during invoke hierarchy setup.

@terminalsin
Copy link
Member

If the target class is empty then there’s something very wrong and that should be investigated over adding a null check and hoping for no side effects

@WeThink25
Copy link
Author

I understand the concern, but an empty method list isn’t necessarily invalid in JVM bytecode. This can legitimately happen with interfaces, marker classes, lambda/synthetic classes, or framework-generated bytecode (for example Paper/Bukkit, ACF, or shaded classes).

The crash happens because the code assumes there is always at least one method and directly accesses index 0. In these cases that assumption doesn’t hold.

Adding a simple guard just skips those non-applicable cases and avoids a hard crash. It doesn’t change behavior for normal, valid hierarchies, and it’s consistent with how other bytecode tools handle synthetic or incomplete class hierarchies.

If the target class is empty then there’s something very wrong and that should be investigated over adding a null check and hoping for no side effects

@WeThink25
Copy link
Author

@terminalsin please look

@terminalsin
Copy link
Member

If that were true to hold, then the class would have an empty method list, not a null one. The fact it holds that it is null has a much more intricate consequence/side effect that would have issues downstream. I need a sample to replicate this, most likely in the form of a test, to ensure this matches JVM spec

@mtalaeii
Copy link

mtalaeii commented Jan 3, 2026

If that were true to hold, then the class would have an empty method list, not a null one. The fact it holds that it is null has a much more intricate consequence/side effect that would have issues downstream. I need a sample to replicate this, most likely in the form of a test, to ensure this matches JVM spec

its happen when we use ACF inside bukkit plugins idk what's wrong in that API but i create simple custom annotation based command system and its work fine with the last version of Skid

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.

3 participants