javassist icon indicating copy to clipboard operation
javassist copied to clipboard

can not instrument replace static method or final method?

Open punkisnotdead3 opened this issue 2 years ago • 0 comments

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?

punkisnotdead3 avatar May 23 '22 12:05 punkisnotdead3