Class LegacyClassLoaderCastTransformer

java.lang.Object
com.hloader.launch.LegacyClassLoaderCastTransformer
All Implemented Interfaces:
ClassFileTransformer

public final class LegacyClassLoaderCastTransformer extends Object implements ClassFileTransformer
Rewrites (URLClassLoader) someClass.getClassLoader() into a call to ClasspathUrls.wrap() wherever it appears in any loaded class. See ClasspathUrls for why this is needed: pre-1.6 Minecraft boots through net.minecraft.launchwrapper.Launch, whose constructor does exactly this cast to read the classpath, and it throws on Java 9+ since the real system class loader is no longer a URLClassLoader.

Only the specific two-instruction sequence Class.getClassLoader() immediately followed by checkcast java/net/URLClassLoader is touched, so unrelated casts of an already-held URLClassLoader reference elsewhere are left alone.

  • Constructor Details

    • LegacyClassLoaderCastTransformer

      public LegacyClassLoaderCastTransformer()
  • Method Details