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

Fix apply failure when mixin method calls clone on an array #147

Closed
wants to merge 1 commit into from

Conversation

jpenilla
Copy link

@jpenilla jpenilla commented Jun 19, 2024

Any Mixin method calling clone on an array will trigger the bug.

Stacktrace:

Caused by: java.lang.NullPointerException: Cannot invoke "org.spongepowered.asm.mixin.transformer.ClassInfo.isMixin()" because the return value of "org.spongepowered.asm.mixin.transformer.ClassInfo.forName(String)" is null
    at org.spongepowered.asm.mixin.transformer.MixinTargetContext.transformMethodRef(MixinTargetContext.java:592)
    at org.spongepowered.asm.mixin.transformer.MixinTargetContext.transformMethod(MixinTargetContext.java:484)
    ... 22 more

Workaround:

public final class MixinWorkarounds {

    public static long[] clone(final long[] values) {
        return values.clone();
    }

}

@LlamaLad7
Copy link
Collaborator

This should be already fixed by my existing changes. Have you tested on the latest release?

@jpenilla
Copy link
Author

Screenshot 2024-06-19 at 12 28 59 PM
The original stacktrace was with these versions (default from latest floader).

Issue still seems present when upgrading to 0.14.0+0.8.6 (running through loom):

[12:31:39] [main/WARN] (FabricLoader/Mixin) Error loading class: [J (java.lang.ClassNotFoundException: [J)
[12:31:39] [main/ERROR] (FabricLoader/Mixin) Mixin apply for mod moonrise failed moonrise.mixins.json:collisions.BitSetDiscreteVoxelShapeMixin from mod moonrise -> net.minecraft.world.phys.shapes.BitSetDiscreteVoxelShape: org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException Unexpecteded NullPointerException whilst transforming the mixin class: [MAIN Applicator Phase -> moonrise.mixins.json:collisions.BitSetDiscreteVoxelShapeMixin from mod moonrise -> Apply Methods -> (Lnet/minecraft/world/phys/shapes/DiscreteVoxelShape;Lnet/minecraft/world/phys/shapes/DiscreteVoxelShape$IntLineConsumer;Z)V:forAllBoxes -> Transform Instructions -> INVOKEVIRTUAL [J::clone()Ljava/lang/Object;]
 org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException: Unexpecteded NullPointerException whilst transforming the mixin class: [MAIN Applicator Phase -> moonrise.mixins.json:collisions.BitSetDiscreteVoxelShapeMixin from mod moonrise -> Apply Methods -> (Lnet/minecraft/world/phys/shapes/DiscreteVoxelShape;Lnet/minecraft/world/phys/shapes/DiscreteVoxelShape$IntLineConsumer;Z)V:forAllBoxes -> Transform Instructions -> INVOKEVIRTUAL [J::clone()Ljava/lang/Object;]
	at org.spongepowered.asm.mixin.transformer.MixinTargetContext.transformMethod(MixinTargetContext.java:520) ~[sponge-mixin-0.14.0+mixin.0.8.6.jar:0.14.0+mixin.0.8.6]
	at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyNormalMethod(MixinApplicatorStandard.java:428) ~[sponge-mixin-0.14.0+mixin.0.8.6.jar:0.14.0+mixin.0.8.6]
	at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyMethods(MixinApplicatorStandard.java:414) ~[sponge-mixin-0.14.0+mixin.0.8.6.jar:0.14.0+mixin.0.8.6]
	at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyMixin(MixinApplicatorStandard.java:281) ~[sponge-mixin-0.14.0+mixin.0.8.6.jar:0.14.0+mixin.0.8.6]
	at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.apply(MixinApplicatorStandard.java:220) ~[sponge-mixin-0.14.0+mixin.0.8.6.jar:0.14.0+mixin.0.8.6]
	at org.spongepowered.asm.mixin.transformer.TargetClassContext.apply(TargetClassContext.java:437) ~[sponge-mixin-0.14.0+mixin.0.8.6.jar:0.14.0+mixin.0.8.6]
	at org.spongepowered.asm.mixin.transformer.TargetClassContext.applyMixins(TargetClassContext.java:418) ~[sponge-mixin-0.14.0+mixin.0.8.6.jar:0.14.0+mixin.0.8.6]
	at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:363) [sponge-mixin-0.14.0+mixin.0.8.6.jar:0.14.0+mixin.0.8.6]
	at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClass(MixinTransformer.java:234) [sponge-mixin-0.14.0+mixin.0.8.6.jar:0.14.0+mixin.0.8.6]
	at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClassBytes(MixinTransformer.java:202) [sponge-mixin-0.14.0+mixin.0.8.6.jar:0.14.0+mixin.0.8.6]
	at net.fabricmc.loader.impl.launch.knot.KnotClassDelegate.getPostMixinClassByteArray(KnotClassDelegate.java:422) [fabric-loader-0.15.11.jar:?]
	at net.fabricmc.loader.impl.launch.knot.KnotClassDelegate.tryLoadClass(KnotClassDelegate.java:323) [fabric-loader-0.15.11.jar:?]
	at net.fabricmc.loader.impl.launch.knot.KnotClassDelegate.loadClass(KnotClassDelegate.java:218) [fabric-loader-0.15.11.jar:?]
	at net.fabricmc.loader.impl.launch.knot.KnotClassLoader.loadClass(KnotClassLoader.java:119) [fabric-loader-0.15.11.jar:?]
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) [?:?]
	at net.minecraft.world.level.block.Block.box(Block.java:154) [minecraft-merged-f32918113c-1.21-loom.mappings.1_21.layered+hash.2198-v2.jar:?]
	at net.minecraft.world.level.block.BaseFireBlock.<clinit>(BaseFireBlock.java:28) [minecraft-merged-f32918113c-1.21-loom.mappings.1_21.layered+hash.2198-v2.jar:?]
	at net.minecraft.server.Bootstrap.bootStrap(Bootstrap.java:52) [minecraft-merged-f32918113c-1.21-loom.mappings.1_21.layered+hash.2198-v2.jar:?]
	at net.minecraft.client.main.Main.main(Main.java:130) [minecraft-merged-f32918113c-1.21-loom.mappings.1_21.layered+hash.2198-v2.jar:?]
	at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:470) [fabric-loader-0.15.11.jar:?]
	at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74) [fabric-loader-0.15.11.jar:?]
	at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23) [fabric-loader-0.15.11.jar:?]
	at net.fabricmc.devlaunchinjector.Main.main(Main.java:86) [dev-launch-injector-0.2.1+build.8.jar:?]
Caused by: java.lang.NullPointerException: Cannot invoke "org.spongepowered.asm.mixin.transformer.ClassInfo.isMixin()" because the return value of "org.spongepowered.asm.mixin.transformer.ClassInfo.forName(String)" is null
	at org.spongepowered.asm.mixin.transformer.MixinTargetContext.transformMethodRef(MixinTargetContext.java:603) ~[sponge-mixin-0.14.0+mixin.0.8.6.jar:0.14.0+mixin.0.8.6]
	at org.spongepowered.asm.mixin.transformer.MixinTargetContext.transformMethod(MixinTargetContext.java:494) ~[sponge-mixin-0.14.0+mixin.0.8.6.jar:0.14.0+mixin.0.8.6]
	... 22 more

@LlamaLad7
Copy link
Collaborator

Ah different issue I see.

@LlamaLad7
Copy link
Collaborator

The change is not unreasonable but I would like first to investigate other places where classes are assumed to have ClassInfos, in case there is a more general solution.

@LlamaLad7 LlamaLad7 closed this in c516fb7 Oct 30, 2024
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