javassist
javassist copied to clipboard
can not instrument replace static method or final method?
like this:
klass.declaredMethods.forEach { ctMethod-> val ctMethodName = ctMethod.name ctMethod.instrument(object : ExprEditor() { override fun edit(m: MethodCall?) { m?.let { methodCall -> when (methodCall.className) { "android.telephony.TelephonyManager" -> { when (methodCall.methodName) { "getDeviceId" -> { m.replace("$_ = FakeTelephonyManager.getFakeDeviceId();") } else -> {
}
}
}
}
}
}
})
}
if method is normal,this replace success but if method is static or final, replace is invalid
why?