Skip to content

Don't run transformers on classes with @Mixin annotation - #8

Open
Tommsy64 wants to merge 1 commit into
LeonPhilips:masterfrom
Tommsy64:master
Open

Don't run transformers on classes with @Mixin annotation#8
Tommsy64 wants to merge 1 commit into
LeonPhilips:masterfrom
Tommsy64:master

Conversation

@Tommsy64

@Tommsy64 Tommsy64 commented Jul 5, 2020

Copy link
Copy Markdown

No description provided.

@LeonPhilips
LeonPhilips marked this pull request as ready for review July 14, 2020 13:34
@LeonPhilips

Copy link
Copy Markdown
Owner

This makes sense: I saw it wasn't ready for review, do you need more time to work on it? Thank you for contributing, by the way!

@Tommsy64

Copy link
Copy Markdown
Author

I made this PR with #7 in mind and realized that it would not fix it as the transformers will still run on inner classes within @Mixin annotated classes. I started writing logic for recursively examining for outer classes; however, I'm misunderstanding something about how ASM handles outer classes, so this isn't working yet.

    public static boolean isMixin(ClassNode classNode) throws IOException {
        if (hasMixinAnnotation(classNode)) {
            return true;
        }
        while (classNode.outerClass != null) {
            String remappedName = FMLDeobfuscatingRemapper.INSTANCE.unmap(classNode.outerClass);
            byte[] outerBytes = TickCentral.LOADER.getClassLoader().getClassBytes(remappedName);
            if (outerBytes == null) {
                TickCentral.LOGGER.warn("Unable to get outer class as resource: " + classNode.outerClass + " (" + FMLDeobfuscatingRemapper.INSTANCE.map(remappedName) + ") Do you have a broken installation? It is referenced in " + classNode.name + " (" + FMLDeobfuscatingRemapper.INSTANCE.map(classNode.name) + ")");
                return false;
            }
            classNode = new ClassNode();
            ClassReader outerReader = new ClassReader(outerBytes);
            outerReader.accept(classNode, ClassReader.SKIP_CODE);
            if (hasMixinAnnotation(classNode)) {
                return true;
            }
        }
        return false;
    }

brunoxkk0 added a commit to brunoxkk0/TickCentral that referenced this pull request Jan 5, 2021
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

Successfully merging this pull request may close these issues.

2 participants