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

Use Mixin for common class resolving #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public static void setup(){

// Hack into knot.
ClassLoader classLoader = Bootstrap.class.getClassLoader();
MixinTransformer.setClassLoader(classLoader); // Needed for ASM, don't ask

try{
// Get classes we can't normally access
Expand Down
15 changes: 2 additions & 13 deletions src/main/java/net/gudenau/minecraft/asm/impl/MixinTransformer.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.transformer.FabricMixinTransformerProxy;
import org.spongepowered.asm.mixin.transformer.IMixinTransformer;
import org.spongepowered.asm.transformers.MixinClassWriter;

/**
* Our custom "mixin" transformer.
Expand Down Expand Up @@ -63,12 +64,6 @@ public class MixinTransformer extends FabricMixinTransformerProxy{
}
}

private static ClassLoader classLoader;

public static void setClassLoader(ClassLoader classLoader){
MixinTransformer.classLoader = classLoader;
}

private final Set<String> seenClasses = new HashSet<>();
private final Locker seenClassesLocker = new Locker();

Expand Down Expand Up @@ -196,13 +191,7 @@ private byte[] transform(String name, String transformedName, byte[] bytecode, L
return bytecode;
}

ClassWriter writer = new ClassWriter(flags.getClassWriterFlags()){
// Fixes an issue with stack calculations
@Override
protected ClassLoader getClassLoader(){
return classLoader;
}
};
ClassWriter writer = new MixinClassWriter(flags.getClassWriterFlags());
classNode.accept(writer);
parentModifier.set(true);
return writer.toByteArray();
Expand Down