Skip to content

Fix CustomClassWriter crash on Java 9+#55

Open
Leclowndu93150 wants to merge 1 commit into
MagicJinn:mainfrom
Leclowndu93150:fix/java9-classwriter
Open

Fix CustomClassWriter crash on Java 9+#55
Leclowndu93150 wants to merge 1 commit into
MagicJinn:mainfrom
Leclowndu93150:fix/java9-classwriter

Conversation

@Leclowndu93150
Copy link
Copy Markdown

CustomClassWriter's static initializer casts Launch.classLoader.getClass().getClassLoader() to URLClassLoader to create a custom class loader for getCommonSuperClass(). Since Java 9, the system class loader is no longer a URLClassLoader, so this cast throws a ClassCastException which permanently poisons the class with NoClassDefFoundError.

Every class the transformer touches (Block, World, EntityLivingBase, EntityRenderer, etc.) then fails to transform, which cascades into other mods' mixins failing too, ultimately crashing the game with ClassNotFoundException: net.minecraft.client.Minecraft.

The fix uses Launch.classLoader directly instead, which is the correct class loader that actually has Minecraft and mod classes. This also changes the catch block to return java/lang/Object instead of throwing, since some classes aren't loadable yet during early transformation (this is the same approach Mixin's own ClassWriter uses).

Works on both Java 8 and Java 9+. Tested on Cleanroom 0.5.12 with Java 25.

@MagicJinn
Copy link
Copy Markdown
Owner

Doing things the proper way is always good, though if you don't mind me asking, is there any specific reproducible crash this solves? I'd love to test it out.

@Leclowndu93150
Copy link
Copy Markdown
Author

Leclowndu93150 commented May 24, 2026

meatballcraft latest version on curseforge using Java 25 (CleanroomMC loader) my fix lets you load the game. i think this also got patched by the latest version of fugue

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