SpongePowered / Mixin

Mixin is a trait/mixin and bytecode weaving framework for Java using ASM
MIT License
1.37k stars 185 forks source link

Support ModLauncher loaded as JPMS Module / Classes-Folder #656

Closed shartte closed 6 months ago

shartte commented 6 months ago

Mixin uses the specification/implementation version of the ModLauncher package to determine compatibility. This breaks when ModLauncher is loaded as a JPMS module (i.e. via module-path), since those two properties are practically dead since the introduction of JPMS. When a JAR is loaded as a module using a standard Classloader (not SJH), then the fields from the Manifest will be ignored and the versions will be null.

This prevents startup of the ModLauncher MixinService, since Package.isCompatibleWith will just throw in that case.

The same problem seems to occur when launching ModLauncher from an exploded directory (i.e. launch via IDE with Mixin on the classpath).

The actual exception, for the record:

Caused by: java.lang.NumberFormatException: Empty version string
    at java.base/java.lang.Package.isCompatibleWith(Package.java:294)
    at org.spongepowered.asm.service.modlauncher.MixinServiceModLauncher.<init>(MixinServiceModLauncher.java:121)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
    at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:789)
    ... 18 more