fix: fix classes having multiple instances of fields

This commit is contained in:
oSumAtrIX 2022-04-05 03:54:16 +02:00
parent 398239dc10
commit 7cc8a7dec3
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4

View File

@ -6,6 +6,7 @@ import app.revanced.patcher.proxy.mutableTypes.MutableMethod.Companion.toMutable
import com.google.common.collect.Iterables
import org.jf.dexlib2.base.reference.BaseTypeReference
import org.jf.dexlib2.iface.ClassDef
import org.jf.dexlib2.util.FieldUtil
import org.jf.dexlib2.util.MethodUtil
class MutableClass(classDef: ClassDef) : ClassDef, BaseTypeReference() {
@ -27,12 +28,8 @@ class MutableClass(classDef: ClassDef) : ClassDef, BaseTypeReference() {
// Fields
private val _fields by lazy { classDef.fields.map { field -> field.toMutable() }.toMutableSet() }
private val _staticFields by lazy {
classDef.staticFields.map { staticField -> staticField.toMutable() }.toMutableSet()
}
private val _instanceFields by lazy {
classDef.instanceFields.map { instanceFields -> instanceFields.toMutable() }.toMutableSet()
}
private val _staticFields by lazy { Iterables.filter(_fields, FieldUtil.FIELD_IS_STATIC).toMutableSet() }
private val _instanceFields by lazy {Iterables.filter(_fields, FieldUtil.FIELD_IS_INSTANCE) .toMutableSet() }
fun setType(type: String) {
this.type = type