From c7f5b0b6b3ce9e663aa5c54b779c9b546e384707 Mon Sep 17 00:00:00 2001 From: Graham Date: Fri, 28 Feb 2020 22:21:34 +0000 Subject: [PATCH] Replace isNative() with more generic getAccess() method --- .../java/dev/openrs2/asm/classpath/AsmClassMetadata.kt | 5 ++--- .../main/java/dev/openrs2/asm/classpath/ClassMetadata.kt | 2 +- .../dev/openrs2/asm/classpath/ReflectionClassMetadata.kt | 8 +++----- .../src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt | 4 +++- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/asm/src/main/java/dev/openrs2/asm/classpath/AsmClassMetadata.kt b/asm/src/main/java/dev/openrs2/asm/classpath/AsmClassMetadata.kt index f98ce568..e4e72fd0 100644 --- a/asm/src/main/java/dev/openrs2/asm/classpath/AsmClassMetadata.kt +++ b/asm/src/main/java/dev/openrs2/asm/classpath/AsmClassMetadata.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 } } diff --git a/asm/src/main/java/dev/openrs2/asm/classpath/ClassMetadata.kt b/asm/src/main/java/dev/openrs2/asm/classpath/ClassMetadata.kt index f593af7f..0a3b80be 100644 --- a/asm/src/main/java/dev/openrs2/asm/classpath/ClassMetadata.kt +++ b/asm/src/main/java/dev/openrs2/asm/classpath/ClassMetadata.kt @@ -11,7 +11,7 @@ abstract class ClassMetadata { abstract val fields: List abstract val methods: List - abstract fun isNative(method: MemberDesc): Boolean + abstract fun getAccess(method: MemberDesc): Int? fun isOverride(method: MemberDesc): Boolean { val superClass = this.superClass diff --git a/asm/src/main/java/dev/openrs2/asm/classpath/ReflectionClassMetadata.kt b/asm/src/main/java/dev/openrs2/asm/classpath/ReflectionClassMetadata.kt index a8884ea1..e8ca3edd 100644 --- a/asm/src/main/java/dev/openrs2/asm/classpath/ReflectionClassMetadata.kt +++ b/asm/src/main/java/dev/openrs2/asm/classpath/ReflectionClassMetadata.kt @@ -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 } } diff --git a/deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt b/deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt index be64c036..19f6ec14 100644 --- a/deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt +++ b/deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt @@ -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 } }