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

Cannot capture locals for class initializers #19

Open
ChloeDawn opened this issue May 17, 2019 · 0 comments
Open

Cannot capture locals for class initializers #19

ChloeDawn opened this issue May 17, 2019 · 0 comments

Comments

@ChloeDawn
Copy link

ChloeDawn commented May 17, 2019

Mixin fails to locate method metadata for class initializers when an injection requests locals capture. The failure occurs at the following point in Locals:

Method methodInfo = classInfo.findMethod(method);
if (methodInfo == null) {
throw new LVTGeneratorException("Could not locate method metadata for " + method.name + " generating LVT in " + classNode.name);
}

A simple reproduction case for net.minecraft.block.Blocks:

@Mixin(Blocks.class)
abstract class BlocksMixin {
  private BlocksMixin() {
    throw new AssertionError();
  }

  @Inject(method = "<clinit>", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;initShapeCache()V"), locals = LocalCapture.CAPTURE_FAILHARD)
  private static void testInjection(final CallbackInfo ci, final Block block, final BlockState state) {}
}

Targetting a loop at the tail of the class initializer, as seen in source:

for(Block block_1 : Registry.BLOCK) {
  for(BlockState blockState_1 : block_1.getStateFactory().getStates()) {
    blockState_1.initShapeCache();
    Block.STATE_IDS.add(blockState_1);
  }

  block_1.getDropTableId();
}

Failing with:

org.spongepowered.asm.util.throwables.LVTGeneratorException: Could not locate method metadata for <clinit> generating LVT in net/minecraft/block/Blocks
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

No branches or pull requests

1 participant