From 64d1b836ed87e8ab465f99a88ecfb609f35eb90a Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 6 Jun 2020 16:11:47 +0100 Subject: [PATCH] Remove dead code before performing final field analysis If we don't do this then we incorrectly mark some fields as final, due to writes present inside if blocks removed by ConstantArgTransformer. Signed-off-by: Graham --- .../java/dev/openrs2/deob/transform/FinalFieldTransformer.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/deob/src/main/java/dev/openrs2/deob/transform/FinalFieldTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/FinalFieldTransformer.kt index f7dbe3165e..f2cae3fec7 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/FinalFieldTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/FinalFieldTransformer.kt @@ -5,6 +5,7 @@ import dev.openrs2.asm.MemberDesc import dev.openrs2.asm.MemberRef import dev.openrs2.asm.classpath.ClassPath import dev.openrs2.asm.classpath.Library +import dev.openrs2.asm.removeDeadCode import dev.openrs2.asm.transform.Transformer import dev.openrs2.deob.analysis.FieldWriteAnalyzer import dev.openrs2.deob.analysis.FieldWriteCount @@ -28,6 +29,8 @@ class FinalFieldTransformer : Transformer() { } override fun transformCode(classPath: ClassPath, library: Library, clazz: ClassNode, method: MethodNode): Boolean { + method.removeDeadCode(clazz.name) + val constructor = method.name == "" || method.name == "" val constructorStatic = (method.access and Opcodes.ACC_STATIC) != 0 val thisCall = if (constructor && !constructorStatic) {