3737import org .objectweb .asm .util .Textifier ;
3838import org .objectweb .asm .util .TraceClassVisitor ;
3939
40+ import net .fabricmc .tinyremapper .IMappingProvider ;
4041import net .fabricmc .tinyremapper .OutputConsumerPath ;
4142import net .fabricmc .tinyremapper .TinyRemapper ;
4243import net .fabricmc .tinyremapper .extension .mixin .MixinExtension ;
43- import net .fabricmc .tinyremapper .extension .mixin .integration .mixins .TargetMixin ;
44- import net .fabricmc .tinyremapper .extension .mixin .integration .targets .Target ;
44+ import net .fabricmc .tinyremapper .extension .mixin .integration .mixins .NonObfuscatedOverrideMixin ;
45+ import net .fabricmc .tinyremapper .extension .mixin .integration .mixins .WildcardTargetMixin ;
46+ import net .fabricmc .tinyremapper .extension .mixin .integration .targets .NonObfuscatedOverrideTarget ;
47+ import net .fabricmc .tinyremapper .extension .mixin .integration .targets .WildcardTarget ;
4548
4649public class MixinIntegrationTest {
4750 @ TempDir
48- static Path folder ;
51+ Path folder ;
4952
5053 @ Test
5154 public void remapWildcardName () throws IOException {
52- Path classpath = createJar (Target .class );
53- Path input = createJar (TargetMixin .class );
55+ String remapped = remap (WildcardTarget .class , WildcardTargetMixin .class , out ->
56+ out .acceptClass ("java/lang/String" , "com/example/NotString" ));
57+
58+ // Check constructor inject did not gain a desc
59+ assertTrue (remapped .contains ("@Lorg/spongepowered/asm/mixin/injection/Inject;(method={\" <init>*\" }" ));
60+ // Check that wildcard desc is remapped without a name
61+ assertTrue (remapped .contains ("@Lorg/spongepowered/asm/mixin/injection/Inject;(method={\" *()Lcom/example/NotString;\" }" ));
62+ }
63+
64+ @ Test
65+ public void remapInvokeNonObfuscatedOverride () throws IOException {
66+ String remapped = remap (NonObfuscatedOverrideTarget .class , NonObfuscatedOverrideMixin .class , out -> {
67+ String fqn = "net/fabricmc/tinyremapper/extension/mixin/integration/targets/NonObfuscatedOverrideTarget" ;
68+ out .acceptClass (fqn , "com/example/Obfuscated" );
69+ out .acceptMethod (new IMappingProvider .Member (fqn , "callAdd" , "(Ljava/lang/Object;)V" ), "obfuscatedCallAdd" );
70+ });
71+
72+ assertTrue (remapped .contains ("@Lorg/spongepowered/asm/mixin/injection/Inject;(method={\" obfuscatedCallAdd\" " ));
73+ // Method is implemented in the target class
74+ assertTrue (remapped .contains ("@Lorg/spongepowered/asm/mixin/injection/At;(value=\" INVOKE\" , target=\" Lcom/example/Obfuscated;add(Ljava/lang/Object;)Z\" " ));
75+ // Method is NOT implemented in the target class and instead comes from unobfuscated super class
76+ assertTrue (remapped .contains ("@Lorg/spongepowered/asm/mixin/injection/At;(value=\" INVOKE\" , target=\" Lcom/example/Obfuscated;addAll(Ljava/util/Collection;)Z\" " ));
77+ }
78+
79+ private String remap (Class <?> target , Class <?> mixin , IMappingProvider mappings ) throws IOException {
80+ Path classpath = createJar (target );
81+ Path input = createJar (mixin );
5482 Path output = folder .resolve ("output.jar" );
5583
5684 TinyRemapper tinyRemapper = TinyRemapper .newRemapper ()
5785 .extension (new MixinExtension ())
58- .withMappings (out -> out . acceptClass ( "java/lang/String" , "com/example/NotString" ) )
86+ .withMappings (mappings )
5987 .build ();
6088
6189 try (OutputConsumerPath outputConsumer = new OutputConsumerPath .Builder (output ).build ()) {
@@ -65,11 +93,7 @@ public void remapWildcardName() throws IOException {
6593 tinyRemapper .apply (outputConsumer );
6694 }
6795
68- String remapped = textify (output , TargetMixin .class );
69- // Check constructor inject did not gain a desc
70- assertTrue (remapped .contains ("@Lorg/spongepowered/asm/mixin/injection/Inject;(method={\" <init>*\" }" ));
71- // Check that wildcard desc is remapped without a name
72- assertTrue (remapped .contains ("@Lorg/spongepowered/asm/mixin/injection/Inject;(method={\" *()Lcom/example/NotString;\" }" ));
96+ return textify (output , mixin );
7397 }
7498
7599 // Create a zip file in the temp dir containing only the passed class file.
0 commit comments