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 <gpe@openrs2.dev>
Graham 5 years ago
parent 6c26fb8b9c
commit 64d1b836ed
  1. 3
      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.MemberRef
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.removeDeadCode
import dev.openrs2.asm.transform.Transformer import dev.openrs2.asm.transform.Transformer
import dev.openrs2.deob.analysis.FieldWriteAnalyzer import dev.openrs2.deob.analysis.FieldWriteAnalyzer
import dev.openrs2.deob.analysis.FieldWriteCount 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 { override fun transformCode(classPath: ClassPath, library: Library, clazz: ClassNode, method: MethodNode): Boolean {
method.removeDeadCode(clazz.name)
val constructor = method.name == "<init>" || method.name == "<clinit>" val constructor = method.name == "<init>" || method.name == "<clinit>"
val constructorStatic = (method.access and Opcodes.ACC_STATIC) != 0 val constructorStatic = (method.access and Opcodes.ACC_STATIC) != 0
val thisCall = if (constructor && !constructorStatic) { val thisCall = if (constructor && !constructorStatic) {

Loading…
Cancel
Save