Skip to content

Mixins for anonymous inner classes not generating refmap entries. #518

@modmuss50

Description

@modmuss50

Issue

Mixins targeting anonymous inner classes such as @Mixin(targets = "net/minecraft/server/network/ServerPlayNetworkHandler$1") (yarn name) fail to get a refmap. Upon building the following warning Mixin target net/minecraft/server/network/ServerPlayNetworkHandler$1 could not be fully resolved. is logged.

I believe it was caused by this FabricMC@b5299bf commit that was included in 0.8.3.

I have a very limited knowlage of the javax.lang.model api, but it seems getTypeElement takes in a canonical name, and anonymous classes dont have such a name. Please let me know if you need any more info.

Many thanks 👍

Reproduction steps:

Tested with this mixin (full mixin is in Fabric API)

import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.util.Hand;
import net.minecraft.util.math.Vec3d;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(targets = "net/minecraft/server/network/ServerPlayNetworkHandler$1")
public class ExampleMixin {
	@Shadow
	public ServerPlayNetworkHandler field_28963;

	@Inject(method = "interactAt(Lnet/minecraft/util/Hand;Lnet/minecraft/util/math/Vec3d;)V", at = @At(value = "HEAD"), cancellable = true)
	public void onPlayerInteractEntity(Hand hand, Vec3d hitPosition, CallbackInfo info) {

	}
}

Expected refmap (0.8.2)

{
  "mappings": {
    "net/fabricmc/example/mixin/ExampleMixin": {
      "interactAt(Lnet/minecraft/util/Hand;Lnet/minecraft/util/math/Vec3d;)V": "Lnet/minecraft/class_3244$1;method_34220(Lnet/minecraft/class_1268;Lnet/minecraft/class_243;)V",
      "net/minecraft/server/network/ServerPlayNetworkHandler$1": "net/minecraft/class_3244$1"
    }
  },
  "data": {
    "named:intermediary": {
      "net/fabricmc/example/mixin/ExampleMixin": {
        "interactAt(Lnet/minecraft/util/Hand;Lnet/minecraft/util/math/Vec3d;)V": "Lnet/minecraft/class_3244$1;method_34220(Lnet/minecraft/class_1268;Lnet/minecraft/class_243;)V",
        "net/minecraft/server/network/ServerPlayNetworkHandler$1": "net/minecraft/class_3244$1"
      }
    }
  }
}

Actual refmap (0.8.4, latest master)

{
  "mappings": {},
  "data": {}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions