raphw / byte-buddy

Runtime code generation for the Java virtual machine.
https://bytebuddy.net
Apache License 2.0
6.23k stars 804 forks source link

Improve diagnostics/troubleshooting features for agent installation #1602

Open sbailliez opened 7 months ago

sbailliez commented 7 months ago

It might be useful to have some better diagnostic features to help troubleshoot the agent misbehaving during the attachment process.

Additional idea to consider, when debugging an agent issue with mockito, I found that the openjdk jvm checks that the .attach_pid<pid> file created has the same uid that the current user and does not attach if they are different, it would be nice to provide a check to help guide the user when such case is detected and make this part of bytebuddy. See https://github.com/mockito/mockito/issues/2436#issuecomment-1966473650 for more details.

raphw commented 7 months ago

I agree with (1) and already added the property to the exception. (4) should come implicit with that as Byte Buddy controls the output within the Attacher main method. I do however not want to offer (2) and (3) for security reasons, this can be debugged differently, I think. When knowing the code, a user can explicitly log the passed statements in a more secure manner, for example. byte-buddy-agent is small enough so that everybody should be able to click through.