fuck java
This commit is contained in:
@@ -7,9 +7,9 @@ import java.nio.file.Path
|
||||
class Knot(private val jar: Path) : ClassFileTransformer {
|
||||
private val knot = "net.fabricmc.loader.impl.launch.knot"
|
||||
private var registry = mutableSetOf<Instrumentation>()
|
||||
override fun transform(classLoader: ClassLoader, className: String,
|
||||
redefined: Class<*>, domain: ProtectionDomain, bytes: ByteArray
|
||||
): ByteArray? = null.also { load(classLoader) }
|
||||
override fun transform(classLoader: ClassLoader?, className: String?,
|
||||
redefined: Class<*>?, domain: ProtectionDomain?, bytes: ByteArray?
|
||||
): ByteArray? = null.also { classLoader?.let { load(it) } }
|
||||
|
||||
fun register(inst: Instrumentation) {
|
||||
val result = runCatching { expose(jar) }
|
||||
@@ -18,7 +18,7 @@ class Knot(private val jar: Path) : ClassFileTransformer {
|
||||
registry.add(inst)
|
||||
}
|
||||
|
||||
private fun delegate() = run {
|
||||
private fun delegate(): Any = run {
|
||||
val base = Class.forName("$knot.KnotClassLoader")
|
||||
val delegate = base.getDeclaredField("delegate")
|
||||
val threads = Thread.getAllStackTraces().keys
|
||||
@@ -27,7 +27,7 @@ class Knot(private val jar: Path) : ClassFileTransformer {
|
||||
delegate.apply { isAccessible = true }.get(knot)
|
||||
}
|
||||
|
||||
private fun expose(jar: Path) = delegate().let {
|
||||
private fun expose(jar: Path): Unit = delegate().let {
|
||||
val base = Class.forName("$knot.KnotClassDelegate")
|
||||
val source = base.getMethod("addCodeSource", Path::class.java)
|
||||
source.apply { isAccessible = true }.invoke(it, jar)
|
||||
|
||||
Reference in New Issue
Block a user