Fix CustomClassWriter crash on Java 9+#55
Open
Leclowndu93150 wants to merge 1 commit into
Open
Conversation
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. |
Author
|
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CustomClassWriter's static initializer casts
Launch.classLoader.getClass().getClassLoader()toURLClassLoaderto create a custom class loader forgetCommonSuperClass(). Since Java 9, the system class loader is no longer aURLClassLoader, so this cast throws aClassCastExceptionwhich permanently poisons the class withNoClassDefFoundError.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.classLoaderdirectly instead, which is the correct class loader that actually has Minecraft and mod classes. This also changes the catch block to returnjava/lang/Objectinstead 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.