Replace isNative() with more generic getAccess() method

master
Graham 5 years ago
parent deb65474c7
commit c7f5b0b6b3
  1. 5
      asm/src/main/java/dev/openrs2/asm/classpath/AsmClassMetadata.kt
  2. 2
      asm/src/main/java/dev/openrs2/asm/classpath/ClassMetadata.kt
  3. 8
      asm/src/main/java/dev/openrs2/asm/classpath/ReflectionClassMetadata.kt
  4. 4
      deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt

@ -27,8 +27,7 @@ class AsmClassMetadata(
override val methods
get() = clazz.methods.map { MemberDesc(it) }.toList()
override fun isNative(method: MemberDesc): Boolean {
val m = clazz.methods.find { it.name == method.name && it.desc == method.desc } ?: return false
return m.access and Opcodes.ACC_NATIVE != 0
override fun getAccess(method: MemberDesc): Int? {
return clazz.methods.find { it.name == method.name && it.desc == method.desc }?.access
}
}

@ -11,7 +11,7 @@ abstract class ClassMetadata {
abstract val fields: List<MemberDesc>
abstract val methods: List<MemberDesc>
abstract fun isNative(method: MemberDesc): Boolean
abstract fun getAccess(method: MemberDesc): Int?
fun isOverride(method: MemberDesc): Boolean {
val superClass = this.superClass

@ -2,7 +2,6 @@ package dev.openrs2.asm.classpath
import dev.openrs2.asm.MemberDesc
import org.objectweb.asm.Type
import java.lang.reflect.Modifier
private val Class<*>.asmName: String
get() = name.replace('.', '/')
@ -29,9 +28,8 @@ class ReflectionClassMetadata(private val classPath: ClassPath, private val claz
override val methods
get() = clazz.declaredMethods.map { MemberDesc(it.name, Type.getMethodDescriptor(it)) }.toList()
override fun isNative(method: MemberDesc): Boolean {
val m = clazz.declaredMethods.find { it.name == method.name && Type.getMethodDescriptor(it) == method.desc }
?: return false
return Modifier.isNative(m.modifiers)
override fun getAccess(method: MemberDesc): Int? {
return clazz.declaredMethods.find { it.name == method.name && Type.getMethodDescriptor(it) == method.desc }
?.modifiers
}
}

@ -7,6 +7,7 @@ import dev.openrs2.asm.classpath.ClassMetadata
import dev.openrs2.asm.classpath.ClassPath
import dev.openrs2.common.collect.DisjointSet
import dev.openrs2.common.indefiniteArticle
import org.objectweb.asm.Opcodes
import org.objectweb.asm.Type
import org.objectweb.asm.commons.Remapper
@ -196,7 +197,8 @@ class TypedRemapper private constructor(
return true
}
if (clazz.isNative(MemberDesc(method))) {
val access = clazz.getAccess(MemberDesc(method))
if (access != null && (access and Opcodes.ACC_NATIVE) != 0) {
return true
}
}

Loading…
Cancel
Save