0

I am using Bytebuddy to instrument methods.

Is there any way of getting hold of runtime information as e.g. the thread id of the instrumented method/constructor ?

I couldn't find a way to gain access to this information using @Advice.*

Ben
  • 191
  • 3
  • 13

2 Answers2

0
java.lang.Thread.currentThread().getName() / getId()
Floern
  • 33,559
  • 24
  • 104
  • 119
0

As using visitor is adding the code inside @Advice.OnMethodEnter and @Advice.OnMethodExit to the beginning and the end of the method respectively, calling Thread.currentThread() inside those annotated methods is resulting in calling the inlined code inside the instrumented method.

Ben
  • 191
  • 3
  • 13