McModLauncher / modlauncher

Java 21 mod launcher
Other
171 stars 47 forks source link

TransformationServices cannot add classes or resources. #111

Closed heisluft closed 11 months ago

heisluft commented 2 years ago

ITransformationService defines two methods

Map.Entry<Set<String>,Supplier<Function<String, Optional<URL>>>> additionalClassesLocator()
Map.Entry<Set<String>,Supplier<Function<String, Optional<URL>>>> additionalResourcesLocator()

for the definition of new sources and resources. However, the Function<String, Optional> will never be called.

The reason behind this lies within https://github.com/McModLauncher/modlauncher/blob/01e32e5e545751576b02133d1d3cbff7e3866b9f/src/main/java/cpw/mods/modlauncher/TransformationServicesHandler.java#L59-L60

The list of locators is constructed but never used afterwards, leading to the locator functions never being called.

Call Stack is provided for conveinience:

de.heisluft.mltest/de.heisluft.mltest.GameLayerBuilder.additionalResourcesLocator(GameLayerBuilder.java:107)
cpw.mods.modlauncher@10.0.1/cpw.mods.modlauncher.TransformationServiceDecorator.getClassLoader(TransformationServiceDecorator.java:141)
java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
java.base/java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1779)
java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
cpw.mods.modlauncher@10.0.1/cpw.mods.modlauncher.TransformationServicesHandler.buildTransformingClassLoader(TransformationServicesHandler.java:59)
cpw.mods.modlauncher@10.0.1/cpw.mods.modlauncher.Launcher.run(Launcher.java:104)

The issue has been persistent since 2880c33583207895f7d9a1377c46ffd8c51867e2

https://github.com/McModLauncher/modlauncher/commit/2880c33583207895f7d9a1377c46ffd8c51867e2#diff-f22f7451e0853b25a8f4b159c4085dd07ed117be6d3bc461b58a9d71504d4a58

heisluft commented 2 years ago

Nota Bene: As LaunchHandlerService#configureTransformationClassLoader is deprecated for removal and The Builder is not in fact used anymore by the TransformingClassLoader constructor, there is no way to define resources to the game. This makes Class.getResource(AsStream) break as the TransformingClassLoader cannot locate any.