Skip to content

Instantly share code, notes, and snippets.

@jakubhalun
Created October 9, 2017 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakubhalun/cbe6dbe910a73dfe1d58c1afd2f5c650 to your computer and use it in GitHub Desktop.
Save jakubhalun/cbe6dbe910a73dfe1d58c1afd2f5c650 to your computer and use it in GitHub Desktop.
Byte Buddy Java Agent working both from command line parameter and Attach API
return new AgentBuilder.Default().disableClassFormatChanges()
.with(AgentBuilder.RedefinitionStrategy.RETRANSFORMATION)
.type(named(className))
.transform(new AgentBuilder.Transformer() {
@Override
public DynamicType.Builder<?> transform(
DynamicType.Builder<?> builder, TypeDescription typeDescription,
ClassLoader classLoader) {
return builder.visit(Advice.to(LoggingAdvice.class).on(
named(methodName)));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment