Repository navigation
Conversation
Mohist forks ModLauncher and securejarhandler, so a few Connector assumptions do not hold there. Detection goes through the "mohist_implementer" launch plugin id: Class.forName on com.mohistmc.* never succeeds, because the server jar sits on the application class loader while Connector runs inside the ModLauncher module layer. The plugin list is read reflectively for that reason, and probing the class path is kept as a fallback. Two places use the flag. IForgeItemMixin targets an interface, which the interface applicator rejects, and the resulting failure aborts the launch while BuiltInRegistries initialises; skipping the mixin on Mohist only loses the piglin bartering redirect. The authlib module move also fails against Mohist's forked securejarhandler, and is now allowed to fail without taking the launch with it.
Fabric ships Mixin 0.12, Forge ships 0.8.5, and three things that work on Fabric do not exist there. DynamicLVTPatch calls Locals.getLocalsAt(ClassNode, MethodNode, AbstractInsnNode, int). That overload arrived in 0.12; on 0.8.x the four argument method takes Locals$Settings, so the call throws NoSuchMethodError and aborts the transformation of the whole jar. The patch is now added only when the overload is present. Interface mixins are checked by MixinPreProcessorInterface, which rejects private and protected methods. Mods use Java 9 private interface methods for injector handlers, so InterfaceMixinAccessWidener promotes them to public, which turns them into default methods with the same body. Injectors declared by an interface mixin are rejected by MixinApplicatorInterface, and a class mixin cannot target an interface either, so the handler cannot be kept at all. InterfaceMixinInjectorStripper removes it and logs what was lost. JarTransformer.cleanupEnvironment also read ClassInfo.nonExpandedCache, a 0.12-only field. The failed lookup skipped the rest of the cleanup, including restoring java/lang/Object in the class cache. The field is optional now.
Mohist rewrites large parts of the vanilla classes that Fabric mods target, so injection points often no longer match. Mixin treats a missing injection point as fatal for the whole target class, and the module class loader then reports the aborted transformation as a missing class, which is hard to trace back to the mixin that caused it. Setting injectors.defaultRequire to 0 in the mixin configs of the transformed mod keeps the mod loading and leaves the affected hook inert. The failures are still logged.
Covers the misleading NoClassDefFoundError, the Mixin 0.8.x gaps, what Mohist does differently, and the known limitations of this approach.
Author
|
I’ve tested it with many Fabric mods (including many that use Mixin; I can provide the mod list if needed). It is normally compatible with Mohist and in fact integrates very well with the Bukkit API ecosystem, which is within expectations. |
This branch has not been deployed
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.
The Issue
Mohist implements the Bukkit API on top of Forge and, in
doing so, forks ModLauncher and securejarhandler. A few assumptions Connector makes do not hold
there, so loading a Fabric mod through Connector on a Mohist server fails during boot — and it
fails in a way that is very hard to trace.
The server dies inside
Bootstrap, naming a vanilla class the mod never touches:The class exists in the runtime jar and
ComposterBlockdoes not reference it. What actuallyhappens is that a mixin failed to apply, Mixin aborted the transformation of its target class, and
ModuleClassLoader.loadClassturned the resultingMixinTransformerErrorinto aClassNotFoundException. BecauseComposterBlock.bootStrap()resolvesItemsfirst, the error isreported at that frame instead of at its cause. Anyone chasing the class name ends up in the wrong
place; the real signal is an earlier
Mixin apply failedline.Three independent gaps produce those failed mixins:
Locals.getLocalsAt(ClassNode, MethodNode, AbstractInsnNode, int)and readsClassInfo.nonExpandedCache. Neither exists in Mixin 0.8.x, where the four-argumentgetLocalsAttakes aLocals$Settings. The resultingNoSuchMethodError/NoSuchFieldExceptionaborts the transformation of the whole jar.MixinPreProcessorInterfacerejects private/protected methods andMixinApplicatorInterfacerejects injectors declared by an interface mixin. Mods that use Java 9private interface methods or interface-mixin injectors — valid on Fabric's Mixin 0.12 — fail here.
injection points frequently no longer match. Mixin treats a missing injection point as fatal for
the entire target class, and the module class loader surfaces the abort as a missing class.
None of these are recoverable by the mod author, and together they make Connector effectively
unusable on Mohist.
The Proposal
Detect Mohist at runtime and degrade gracefully only where its forked loader/Mixin cannot honour
Connector's assumptions. The changes are split across four commits:
Add Mohist runtime detection (
MohistCompat,ConnectorLoaderService,ConnectorBootstrap)MohistCompat.isMohistRuntime()(cached) looks for themohist_implementerlaunch-plugin id byreflecting into ModLauncher's private
launchPluginsfield, with a classpath probe(
com.mohistmc.MohistMCStart/com.mohistmc.MohistMCon the ModLauncher, system and platformclass loaders) as a fallback. Detection cannot use
Class.forNamealone: the Mohist server jarsits on the application class loader while Connector runs inside the ModLauncher module layer.
ConnectorLoaderServicelogs the active mode and wraps the authlib module move in a try/catch —Mohist's forked securejarhandler does not always accept it, and losing it only affects Fabric
API internals, not startup.
ConnectorBootstrap.shouldApplyMixinskipsIForgeItemMixinon Mohist. It targets an interface,which the interface applicator rejects, and that failure aborts the launch during
BuiltInRegistriesinit; skipping it only loses the piglin-bartering redirect.Handle interface mixins and the Locals API on Mixin 0.8.x (
MixinPatchTransformer,JarTransformer,InterfaceMixinAccessWidener,InterfaceMixinInjectorStripper)DynamicLVTPatchis added only when the 4-argLocals.getLocalsAt(...)overload is present(
hasExtendedLocalsApi()), so 0.8.x no longer throwsNoSuchMethodErrormid-transformation.InterfaceMixinAccessWidenerpromotes non-public methods declared by interface mixins to public,turning Java 9 private interface methods into default methods with the same body so
MixinPreProcessorInterfaceaccepts them.InterfaceMixinInjectorStripperremoves injector handlers from interface mixins (both Mixin andMixinExtras injectors).
MixinApplicatorInterfacecannot apply them and a class mixin may nottarget an interface, so dropping the handler is the only option; every removed handler is logged
at WARN.
JarTransformer.cleanupEnvironmenttreatsClassInfo.nonExpandedCacheas optional. On 0.8.x thelookup used to throw and skip the rest of cleanup, including restoring
java/lang/Objectin theclass cache.
Downgrade unmatched injections to warnings on Mohist (
MixinPatchTransformer)finalize()writesinjectors.defaultRequire = 0into each transformed mod's mixinconfig (idempotent, pretty-printed). Missing injection points then become warnings instead of a
fatal class-transformation abort, so the mod loads with the affected hook inert.
Document running Connector on Mohist (
MOHIST.md)NoClassDefFoundError, the Mixin 0.8.x gaps, what Mohist doesdifferently, the known limitations, and how to run it.
Possible Side Effects
MohistCompat.isMohistRuntime()exceptthe Mixin-version guards (
hasExtendedLocalsApi, optionalnonExpandedCache), which are pureno-ops on 0.12+ and simply prevent a crash on 0.8.x. Regular Forge / Fabric-runtime behaviour is
unchanged.
defaultRequire = 0and interface-mixin injector stripping,a mod will load even when some injection points no longer match on Mohist. The affected hooks do
nothing. This is logged (WARN per removed handler, warnings per unmatched injection), but it is a
correctness trade-off: a mod may appear to work while one of its features is quietly inactive.
IForgeItemMixinis skipped on Mohist, so the piglin-bartering redirect is not applied there.MohistCompatreads a private ModLauncher field (launchPlugins) andprobes the system/platform class loaders. If ModLauncher's internals change, detection falls back
to the classpath probe and, if that also fails, simply reports "not Mohist" (safe default).
DynamicLVTPatchis not applied where the extended Locals API is absent, so LVT-dependent patchesare not rewritten in that environment — but they previously crashed the jar transformation there,
so this only changes a hard failure into a successful, partially-patched load.
Alternatives
Class.forName("com.mohistmc.*"). Rejected — it never succeeds, because theMohist server jar is on the application class loader while Connector runs inside the ModLauncher
module layer. That is why detection goes through the launch-plugin list and explicit class loaders.
Fabric mods on Mohist, not merely to explain why they cannot. A clear error message is still
emitted for the cases that remain unsupported.
may not target an interface, and the interface applicator rejects injectors outright. Removing the
handler (and logging it) is the only path that lets the mod load.
Mohist ships 0.8.5 and forks the loader; we cannot change the Mixin version it runs.
Additional Notes
-Xmx2Gis not enough (world generation OOMs while preparing the nether);-Xmx4Gworks.1.20.1branch (Forge 47.x / Mixin 0.8.5). The changes are scoped to thetransformation/loader path and do not touch the hot path at runtime.
MOHIST.mddocuments the symptoms, root causes, limitations (@At("STORE")with@Injectisrejected by 0.8.5; mixins Mohist applies itself are outside Connector's transformation), and how to
run it (including deleting
mods/.connectorafter replacing the Connector jar, or the cachedtransformation is reused).