Add ClassNameExtensions

bzip2
Graham 5 years ago
parent c7f5b0b6b3
commit 3c7989455b
  1. 9
      asm/src/main/java/dev/openrs2/asm/ClassNameExtensions.kt
  2. 5
      asm/src/main/java/dev/openrs2/asm/classpath/ClassPath.kt
  3. 3
      asm/src/main/java/dev/openrs2/asm/classpath/ReflectionClassMetadata.kt

@ -0,0 +1,9 @@
package dev.openrs2.asm
fun String.toBinaryClassName(): String {
return replace('/', '.')
}
fun String.toInternalClassName(): String {
return replace('.', '/')
}

@ -2,6 +2,7 @@ package dev.openrs2.asm.classpath
import dev.openrs2.asm.MemberDesc
import dev.openrs2.asm.MemberRef
import dev.openrs2.asm.toBinaryClassName
import dev.openrs2.common.collect.DisjointSet
import dev.openrs2.common.collect.ForestDisjointSet
import org.objectweb.asm.commons.Remapper
@ -40,10 +41,8 @@ class ClassPath(
}
}
val reflectionName = name.replace('/', '.')
val clazz = try {
runtime.loadClass(reflectionName)
runtime.loadClass(name.toBinaryClassName())
} catch (ex: ClassNotFoundException) {
throw IllegalArgumentException("Unknown class $name")
}

@ -1,10 +1,11 @@
package dev.openrs2.asm.classpath
import dev.openrs2.asm.MemberDesc
import dev.openrs2.asm.toInternalClassName
import org.objectweb.asm.Type
private val Class<*>.asmName: String
get() = name.replace('.', '/')
get() = name.toInternalClassName()
class ReflectionClassMetadata(private val classPath: ClassPath, private val clazz: Class<*>) : ClassMetadata() {
override val name: String

Loading…
Cancel
Save