Rafael Winterhalter
Rafael Winterhalter
Good catch, thanks!
You can use *byte-buddy-agent* to self-attach also within Docker: `ByteBuddyAgent.install()`. You can then execute the premain method manually.
Byte Buddy does support such emulation. Have a look at *byte-buddy-agent* and use JNA as an additional dependency.
It should be, but we struggled to build Mockito with a module-info in place. I did not have time to look into that yet.
You can use `FieldAccessor` for this. For example, `FieldAccessor.ofField("firstField").setsArgumentAt(1)` for the first line. You can then compose these statements via `andThen()` on the result.
It does not help to add an inner class property as this is merely cosmetic. What would help would be to manipulate the nestmates attribute, but that is not possible...
Can you show your interceptor class?
Did you include Byte Buddy in your jar? The agent needs to pack all of its dependencies.
The functionality you are looking for is called `MemberSubstitution`, where you can replace all interactions with a different method of your choice. Byte Buddy also supports Android builds: https://github.com/raphw/byte-buddy/tree/master/byte-buddy-gradle-plugin/android-plugin
I would assume your replacement method should be static? Is there no exception or anything? Worst case, intercept the visitMethod method in the MemberSubstitution with a debugger to see why...