Remove native library loading logic for SunOS/Solaris

The native library replacements haven't been built for them.

Signed-off-by: Graham <gpe@openrs2.dev>
bzip2
Graham 5 years ago
parent 040fc87f0d
commit dd06bb2f83
  1. 25
      bundler/src/main/java/dev/openrs2/bundler/transform/LoadLibraryTransformer.kt

@ -5,7 +5,9 @@ import dev.openrs2.asm.InsnMatcher
import dev.openrs2.asm.classpath.ClassPath import dev.openrs2.asm.classpath.ClassPath
import dev.openrs2.asm.classpath.Library import dev.openrs2.asm.classpath.Library
import dev.openrs2.asm.transform.Transformer import dev.openrs2.asm.transform.Transformer
import org.objectweb.asm.Opcodes
import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.ClassNode
import org.objectweb.asm.tree.JumpInsnNode
import org.objectweb.asm.tree.LdcInsnNode import org.objectweb.asm.tree.LdcInsnNode
import org.objectweb.asm.tree.MethodNode import org.objectweb.asm.tree.MethodNode
import javax.inject.Singleton import javax.inject.Singleton
@ -14,10 +16,12 @@ import javax.inject.Singleton
class LoadLibraryTransformer : Transformer() { class LoadLibraryTransformer : Transformer() {
private var jnilibs = 0 private var jnilibs = 0
private var amd64Checks = 0 private var amd64Checks = 0
private var sunOsChecks = 0
override fun preTransform(classPath: ClassPath) { override fun preTransform(classPath: ClassPath) {
jnilibs = 0 jnilibs = 0
amd64Checks = 0 amd64Checks = 0
sunOsChecks = 0
} }
override fun transformCode(classPath: ClassPath, library: Library, clazz: ClassNode, method: MethodNode): Boolean { override fun transformCode(classPath: ClassPath, library: Library, clazz: ClassNode, method: MethodNode): Boolean {
@ -34,16 +38,35 @@ class LoadLibraryTransformer : Transformer() {
} }
} }
for (match in SUNOS_CHECK_MATCHER.match(method)) {
val ldc = match[1] as LdcInsnNode
if (ldc.cst == "sunos") {
method.instructions.remove(match[0])
method.instructions.remove(match[1])
method.instructions.remove(match[2])
val jump = match[3] as JumpInsnNode
if (jump.opcode == Opcodes.IFEQ) {
method.instructions.set(jump, JumpInsnNode(Opcodes.GOTO, jump.label))
} else {
method.instructions.remove(jump)
}
sunOsChecks++
}
}
return false return false
} }
override fun postTransform(classPath: ClassPath) { override fun postTransform(classPath: ClassPath) {
logger.info { "Replaced $jnilibs jnilibs with dylibs and removed $amd64Checks amd64 jagmisc checks" } logger.info { "Replaced $jnilibs jnilibs with dylibs" }
logger.info { "Removed $amd64Checks amd64 jagmisc and $sunOsChecks SunOS checks" }
} }
private companion object { private companion object {
private val logger = InlineLogger() private val logger = InlineLogger()
private val AMD64_CHECK_MATCHER = private val AMD64_CHECK_MATCHER =
InsnMatcher.compile("GETSTATIC LDC INVOKEVIRTUAL IFNE GETSTATIC LDC INVOKEVIRTUAL IFNE") InsnMatcher.compile("GETSTATIC LDC INVOKEVIRTUAL IFNE GETSTATIC LDC INVOKEVIRTUAL IFNE")
private val SUNOS_CHECK_MATCHER = InsnMatcher.compile("GETSTATIC LDC INVOKEVIRTUAL (IFNE | IFEQ)")
} }
} }

Loading…
Cancel
Save