I'm trying to modify some code in static initializer with m.replace("$_ = ($r)false;")
, but I got NPE:
Caused by: java.lang.NullPointerException
at javassist.bytecode.ConstPool.getMethodrefNameAndType(ConstPool.java:418)
at javassist.expr.MethodCall.getNameAndType(MethodCall.java:43)
at javassist.expr.MethodCall.getMethodName(MethodCall.java:107)
at com.github.gfx.javassistexamp.JavassistExample$2.edit(JavassistExample.groovy:29)
at javassist.expr.ExprEditor.loopBody(ExprEditor.java:192)
at javassist.expr.ExprEditor.doit(ExprEditor.java:91)
at javassist.CtBehavior.instrument(CtBehavior.java:712)
at javassist.CtBehavior$instrument.call(Unknown Source)
I guess it is because the static initializer has no method name, but ClassPool expects a method (behavior) should have a name.