简体   繁体   中英

How can I instrument/intercept Method.invoke in a ByteBuddy agent?

This doesn't seem to work:

new AgentBuilder
  .Default()
  .with(initStrat)
  .ignore(not(is(Method.class)))
  .type(any()).transform(....)

Also, I only want to intercept java.lang.reflect.Method.invoke and not other methods of the Method class.

Also where in the code can I see the list of classes, packages, and modules that are ignored by default?

This seems about right but instrumenting classes on the boot class is specially tricky since your agent will not be visible to such classes. In the transformer add your instrumentation and restrict it to the invoke method by an appropriate matcher.

Add a AgentBuilder.Listener to get notifications on all classes that are instrumented by Byte Buddy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM