Garmaine Staff asked 4 months ago

I have a large 3rd party code base I can't modify, but I need to make a small but important change in many different places. I was hoping to use a ByteBuddy based agent, but I can't figure out how. The call I need to replace is of the form:

SomeSystemClass.someMethod("foo")

and I need to replace it with

SomeSystemClass.someMethod("bar")

while leaving all other calls to the same method untouched

SomeSystemClass.someMethod("ignore me")

Since SomeSystemClass is a JDK class, I do not want to advise it, but only the classes that contain calls to it. How can this be done?

Note that:

  1. someMethod is static and
  2. the calls (at least some of them) are inside a static initializer block