Class LegacyClassLoaderCastTransformer
java.lang.Object
com.hloader.launch.LegacyClassLoaderCastTransformer
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ClassFileTransformer
transform
-
Constructor Details
-
LegacyClassLoaderCastTransformer
public LegacyClassLoaderCastTransformer()
-
-
Method Details
-
transform
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) - Specified by:
transformin interfaceClassFileTransformer
-