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 1e3df6713a..f7dbe3165e 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/FinalFieldTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/FinalFieldTransformer.kt @@ -98,6 +98,24 @@ class FinalFieldTransformer : Transformer() { return false } + override fun transformClass(classPath: ClassPath, library: Library, clazz: ClassNode): Boolean { + // if a class has no constructor all its fields must be non-final + + val hasInstanceConstructor = clazz.methods.any { it.name == "" } + val hasStaticConstructor = clazz.methods.any { it.name == "" } + + for (field in clazz.fields) { + val fieldStatic = (field.access and Opcodes.ACC_STATIC) != 0 + + if ((!hasInstanceConstructor && !fieldStatic) || (!hasStaticConstructor && fieldStatic)) { + val partition = inheritedFieldSets[MemberRef(clazz, field)]!! + nonFinalFields += partition + } + } + + 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)]!!