LlamaLad7 / MixinExtras

Companion library to SpongePowered Mixin with many custom injectors for a more expressive experience.
MIT License
309 stars 17 forks source link

LocalRef error can happen when you capture a ref as a lambda parameter #45

Closed MattiDragon closed 1 year ago

MattiDragon commented 1 year ago

You can get the following error when you capture a localref variable in a lambda or otherwise, such that it is only read after the handler completes:

java.lang.IllegalStateException: Uninitialized LocalRef! This should never happen! Please report to LlamaLad7!

In my case I was messing with executors in resource reload code and accidentally captured it in a lambda that executes on another thread. This is easy to work around on the user side, and I don't see how mixin extras could resonably support using variables later, but it would be nice if the error on a disposed localref would be different from an uninitialized one.

Mostly just reporting because the error is somewhat misleading

LlamaLad7 commented 1 year ago

You're probably right that there should be 2 error messages, will fix. The one for a disposed ref should also most likely explain that it's probably the user's fault.

LlamaLad7 commented 1 year ago

Done in 0.2.0-rc.2