Fabric API

Fabric API

106M Downloads

minor mixin improvements

UpcraftLP opened this issue ยท 5 comments

commented

enabling mixin debug output produces unnecessary log spam due to fabric api modules not following mixin guidelines.

  • @Shadow target fabric-registry-sync-v0.mixins.json:MixinIdList::idMap is final but shadow is not decorated with @Final
  • @Shadow target fabric-registry-sync-v0.mixins.json:MixinIdList::list is final but shadow is not decorated with @Final
  • @Shadow target fabric-resource-loader-v0.mixins.json:MixinReloadableResourceManagerImpl::type is final but shadow is not decorated with @Final
  • @Shadow target fabric-registry-sync-v0.mixins.json:client.MixinBlockColorMap::providers is final but shadow is not decorated with @Final
  • @Shadow target fabric-registry-sync-v0.mixins.json:client.MixinItemColorMap::providers is final but shadow is not decorated with @Final
  • @Shadow target fabric-registry-sync-v0.mixins.json:client.MixinItemModelMap::modelIds is final but shadow is not decorated with @Final
  • hadow target fabric-registry-sync-v0.mixins.json:client.MixinItemModelMap::models is final but shadow is not decorated with @Final
  • @Shadow target fabric-registry-sync-v0.mixins.json:client.MixinParticleManager::factories is final but shadow is not decorated with @Final
commented

Is it a good idea to decorate these with @Final? What if another mod wants to AW them... wouldn't that lead to crashes?

@Final doesn't make a field final, it causes Mixin to prevent writes to the shadowed field within the mixin. Writes outside of that specific mixin are unaffected.

On an Shadow field, it can be used to raise an error-level log message if any write occurrences appear in the mixin bytecode. This can be used in place of declaring the field as actually final. This is required since it is normally desirable to remove the final modifier from shadow fields to avoid unwanted field initialisers. If MixinEnvironment.Option.DEBUG_VERIFY is true, then an InvalidMixinException is thrown.

https://jenkins.liteloader.com/view/Other/job/Mixin/javadoc/org/spongepowered/asm/mixin/Final.html

commented

I wouldn't follow the list given in this issue's description given that it is about two years out of date. Could someone post an updated list for tracking here?

commented

Is it a good idea to decorate these with @Final? What if another mod wants to AW them... wouldn't that lead to crashes?

commented

This is fixed (but not validated) by: #2540

commented

Fixing these would aid towards #587