Allow final modifier to replace volatile modifier

volatile is pointless if a field is final - even on arrays/objects, as
it only applies to the reference, not the contents of the target.

Signed-off-by: Graham <gpe@openrs2.dev>
Graham 5 years ago
parent 64d1b836ed
commit 327a6f0e3f
  1. 12
      deob/src/main/java/dev/openrs2/deob/transform/FinalFieldTransformer.kt

@ -14,7 +14,6 @@ import dev.openrs2.util.collect.DisjointSet
import org.objectweb.asm.Opcodes import org.objectweb.asm.Opcodes
import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.ClassNode
import org.objectweb.asm.tree.FieldInsnNode import org.objectweb.asm.tree.FieldInsnNode
import org.objectweb.asm.tree.FieldNode
import org.objectweb.asm.tree.MethodInsnNode import org.objectweb.asm.tree.MethodInsnNode
import org.objectweb.asm.tree.MethodNode import org.objectweb.asm.tree.MethodNode
import org.objectweb.asm.tree.analysis.Analyzer import org.objectweb.asm.tree.analysis.Analyzer
@ -119,15 +118,6 @@ class FinalFieldTransformer : Transformer() {
return false return false
} }
override fun transformField(classPath: ClassPath, library: Library, clazz: ClassNode, field: FieldNode): Boolean {
if ((field.access and Opcodes.ACC_VOLATILE) != 0) {
val partition = inheritedFieldSets[MemberRef(clazz, field)]!!
nonFinalFields += partition
}
return false
}
override fun postTransform(classPath: ClassPath) { override fun postTransform(classPath: ClassPath) {
var fieldsChanged = 0 var fieldsChanged = 0
@ -142,7 +132,7 @@ class FinalFieldTransformer : Transformer() {
if (nonFinalFields.contains(partition)) { if (nonFinalFields.contains(partition)) {
field.access = field.access and Opcodes.ACC_FINAL.inv() field.access = field.access and Opcodes.ACC_FINAL.inv()
} else { } else {
field.access = field.access or Opcodes.ACC_FINAL field.access = (field.access or Opcodes.ACC_FINAL) and Opcodes.ACC_VOLATILE.inv()
} }
if (field.access != access) { if (field.access != access) {

Loading…
Cancel
Save