From 9a1599880b53e486f3ec292d6d636ebc6fb3e81a Mon Sep 17 00:00:00 2001 From: Major Date: Sat, 7 Mar 2020 15:10:18 +0000 Subject: [PATCH] Don't rename classes containing native methods Signed-off-by: Major --- .../java/dev/openrs2/deob/remap/TypedRemapper.kt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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 185fa565..9ee06a34 100644 --- a/deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt +++ b/deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt @@ -109,7 +109,7 @@ class TypedRemapper private constructor( clazz: ClassMetadata ): String { val name = clazz.name - if (mapping.containsKey(name) || name in EXCLUDED_CLASSES || clazz.dependency) { + if (mapping.containsKey(name) || !isClassRenamable(clazz)) { return mapping.getOrDefault(name, name) } @@ -190,6 +190,20 @@ class TypedRemapper private constructor( return mapping } + private fun isClassRenamable(clazz: ClassMetadata): Boolean { + if (clazz.name in EXCLUDED_CLASSES || clazz.dependency) { + return false + } + + for (method in clazz.methods) { + if (clazz.getAccess(method)!! and Opcodes.ACC_NATIVE != 0) { + return false + } + } + + return true + } + fun isMethodImmutable(classPath: ClassPath, partition: DisjointSet.Partition): Boolean { for (method in partition) { val clazz = classPath[method.owner]!!