Mixin icon indicating copy to clipboard operation
Mixin copied to clipboard

Mixin hotswapping broken in modlauncher

Open Niko-sk2x opened this issue 5 years ago • 1 comments

Trying to hotswap changes to almost any mixin causes an exception like this, causing hotswap to fail:

[21:22:25] [JDWP Transport Listener: dt_socket/ERROR] [mi.agent/]: Error while re-transforming target class net/minecraft/world/chunk/listener/TrackingChunkStatusListener
java.lang.UnsupportedOperationException: class redefinition failed: attempted to change superclass or interfaces
	at sun.instrument.InstrumentationImpl.redefineClasses0(Native Method) ~[?:1.8.0_242] {}
	at sun.instrument.InstrumentationImpl.redefineClasses(InstrumentationImpl.java:170) ~[?:1.8.0_242] {}
	at org.spongepowered.tools.agent.MixinAgent$Transformer.reApplyMixins(MixinAgent.java:121) [mixin-0.8.jar:0.8+unknown-b0.git-unknown] {}
	at org.spongepowered.tools.agent.MixinAgent$Transformer.transform(MixinAgent.java:72) [mixin-0.8.jar:0.8+unknown-b0.git-unknown] {}
	at sun.instrument.TransformerManager.transform(TransformerManager.java:188) [?:1.8.0_242] {}
	at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428) [?:1.8.0_242] {}

This can sometimes cause different kinds of errors, including some vanilla class failing to initialize.

I think the root cause of this is ModLauncherClassProvider using Thread.currentThread().getContextClassLoader() which is NOT going to be the modlauncher classloader on the instrumentation thread, so it's trying to redefine the wrong class.

Niko-sk2x avatar Jun 05 '20 19:06 Niko-sk2x

Ok I'll look into that.

Mumfrey avatar Jun 18 '20 12:06 Mumfrey