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

Non-static inner classes in mixins cause crash due to incorrect ASM shading #3

Closed
makamys opened this issue Sep 26, 2022 · 1 comment

Comments

@makamys
Copy link

makamys commented Sep 26, 2022

Example:

package org.embeddedt.archaicfix.mixins.client.core;

import net.minecraft.client.Minecraft;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(Minecraft.class)
public abstract class MixinMinecraft {

    @Redirect(method = "runGameLoop", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;isActive()Z", remap = false))
    private boolean alwaysHaveDisplayActive() {
        new TestInnerClass().test();
        return true;
    }
    
    private class TestInnerClass {
        public void test() {
            System.out.println("hi");
        }
    }
}

This works with SpongeMixins 1.2.0, but with GasStation it crashes with the following exception:

Caused by: java.lang.NoSuchMethodError: org.objectweb.asm.commons.Remapper.mapInnerClassName(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
	at org.spongepowered.asm.lib.commons.ClassRemapper.visitInnerClass(ClassRemapper.java:204) ~[00gasstation-mc1.7.10-0.3.4.jar:?]

This happens because references to org.objectweb.asm.commons.Remapper are not remapped in ClassRemapper, causing the ASM 5.0.3 version of the class to get used, which does not have the mapInnerClassName method.

The same crash happens when running Hodgepodge with speedupBOPFogHandling enabled, as their mixin also has a non-static inner class.

Full stack trace
java.lang.NoClassDefFoundError: net/minecraft/client/Minecraft$TestInnerClass$c7d2ff69cb2049e09ebbf6b9b094703a
	at net.minecraft.client.Minecraft.redirect$zdc000$alwaysHaveDisplayActive(Minecraft.java:2939) ~[bao.class:?]
	at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1009) ~[bao.class:?]
	at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:898) [bao.class:?]
	at net.minecraft.client.main.Main.main(SourceFile:148) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_332]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_332]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_332]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_332]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_332]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_332]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_332]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_332]
	at org.multimc.impl.OneSixLauncher.invokeMain(OneSixLauncher.java:104) [NewLaunch.jar:?]
	at org.multimc.impl.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:175) [NewLaunch.jar:?]
	at org.multimc.impl.OneSixLauncher.launch(OneSixLauncher.java:185) [NewLaunch.jar:?]
	at org.multimc.EntryPoint.listen(EntryPoint.java:127) [NewLaunch.jar:?]
	at org.multimc.EntryPoint.main(EntryPoint.java:57) [NewLaunch.jar:?]
Caused by: java.lang.ClassNotFoundException: net.minecraft.client.Minecraft$TestInnerClass$c7d2ff69cb2049e09ebbf6b9b094703a
	at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) ~[launchwrapper-1.12.jar:?]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[?:1.8.0_332]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_332]
	... 19 more
Caused by: java.lang.NoSuchMethodError: org.objectweb.asm.commons.Remapper.mapInnerClassName(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
	at org.spongepowered.asm.lib.commons.ClassRemapper.visitInnerClass(ClassRemapper.java:204) ~[00gasstation-mc1.7.10-0.3.4.jar:?]
	at org.spongepowered.asm.mixin.transformer.InnerClassGenerator$InnerClassAdapter.visitInnerClass(InnerClassGenerator.java:249) ~[00gasstation-mc1.7.10-0.3.4.jar:?]
	at org.spongepowered.asm.lib.tree.InnerClassNode.accept(InnerClassNode.java:83) ~[00gasstation-mc1.7.10-0.3.4.jar:?]
	at org.spongepowered.asm.lib.tree.ClassNode.accept(ClassNode.java:438) ~[00gasstation-mc1.7.10-0.3.4.jar:?]
	at org.spongepowered.asm.mixin.transformer.InnerClassGenerator$InnerClassInfo.accept(InnerClassGenerator.java:158) ~[00gasstation-mc1.7.10-0.3.4.jar:?]
	at org.spongepowered.asm.mixin.transformer.InnerClassGenerator.generate(InnerClassGenerator.java:367) ~[00gasstation-mc1.7.10-0.3.4.jar:?]
	at org.spongepowered.asm.mixin.transformer.InnerClassGenerator.generate(InnerClassGenerator.java:354) ~[00gasstation-mc1.7.10-0.3.4.jar:?]
	at org.spongepowered.asm.mixin.transformer.MixinClassGenerator.generateClass(MixinClassGenerator.java:81) ~[00gasstation-mc1.7.10-0.3.4.jar:?]
	at org.spongepowered.asm.mixin.transformer.MixinTransformer.generateClass(MixinTransformer.java:263) ~[00gasstation-mc1.7.10-0.3.4.jar:?]
	at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClassBytes(MixinTransformer.java:199) ~[00gasstation-mc1.7.10-0.3.4.jar:?]
	at org.spongepowered.asm.mixin.transformer.Proxy.transform(Proxy.java:72) ~[00gasstation-mc1.7.10-0.3.4.jar:?]
	at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279) ~[launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176) ~[launchwrapper-1.12.jar:?]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[?:1.8.0_332]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_332]
	... 19 more

Mod list

archaicfix-mc1.7.10-0.3.2-1-gc3c660f.dirty.jar
falsepatternlib-mc1.7.10-0.10.10.jar
SpongeMixins-1.2.0.jar OR 00gasstation-mc1.7.10-0.3.4.jar
@makamys
Copy link
Author

makamys commented Sep 28, 2022

Fixed in 0.3.5.

@makamys makamys closed this as completed Sep 28, 2022
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