Class AgentBuilder.Listener.StreamWriting

java.lang.Object
net.bytebuddy.agent.builder.AgentBuilder.Listener.StreamWriting
All Implemented Interfaces:
AgentBuilder.Listener
Enclosing interface:
AgentBuilder.Listener

@Enhance public static class AgentBuilder.Listener.StreamWriting extends Object implements AgentBuilder.Listener
A listener that writes events to a PrintStream. This listener prints a line per event, including the event type and the name of the type in question.
  • Field Details

    • PREFIX

      protected static final String PREFIX
      The prefix that is appended to all written messages.
      See Also:
    • printStream

      private final PrintStream printStream
      The print stream written to.
  • Constructor Details

    • StreamWriting

      public StreamWriting(PrintStream printStream)
      Creates a new stream writing listener.
      Parameters:
      printStream - The print stream written to.
  • Method Details

    • toSystemOut

      public static AgentBuilder.Listener.StreamWriting toSystemOut()
      Creates a new stream writing listener that writes to System.out.
      Returns:
      A listener writing events to the standard output stream.
    • toSystemError

      public static AgentBuilder.Listener.StreamWriting toSystemError()
      Creates a new stream writing listener that writes to System.err.
      Returns:
      A listener writing events to the standard error stream.
    • withTransformationsOnly

      public AgentBuilder.Listener withTransformationsOnly()
      Returns a version of this listener that only reports successfully transformed classes and failed transformations.
      Returns:
      A version of this listener that only reports successfully transformed classes and failed transformations.
    • withErrorsOnly

      public AgentBuilder.Listener withErrorsOnly()
      Returns a version of this listener that only reports failed transformations.
      Returns:
      A version of this listener that only reports failed transformations.
    • onDiscovery

      public void onDiscovery(String typeName, @MaybeNull ClassLoader classLoader, @MaybeNull JavaModule module, boolean loaded)
      Invoked upon a type being supplied to a transformer.
      Specified by:
      onDiscovery in interface AgentBuilder.Listener
      Parameters:
      typeName - The binary name of the instrumented type.
      classLoader - The class loader which is loading this type or null if loaded by the boots loader.
      module - The instrumented type's module or null if the current VM does not support modules.
      loaded - true if the type is already loaded.
    • onTransformation

      public void onTransformation(TypeDescription typeDescription, @MaybeNull ClassLoader classLoader, @MaybeNull JavaModule module, boolean loaded, DynamicType dynamicType)
      Invoked prior to a successful transformation being applied.
      Specified by:
      onTransformation in interface AgentBuilder.Listener
      Parameters:
      typeDescription - The type that is being transformed.
      classLoader - The class loader which is loading this type or null if loaded by the boots loader.
      module - The transformed type's module or null if the current VM does not support modules.
      loaded - true if the type is already loaded.
      dynamicType - The dynamic type that was created.
    • onIgnored

      public void onIgnored(TypeDescription typeDescription, @MaybeNull ClassLoader classLoader, @MaybeNull JavaModule module, boolean loaded)
      Invoked when a type is not transformed but ignored.
      Specified by:
      onIgnored in interface AgentBuilder.Listener
      Parameters:
      typeDescription - The type being ignored for transformation.
      classLoader - The class loader which is loading this type or null if loaded by the boots loader.
      module - The ignored type's module or null if the current VM does not support modules.
      loaded - true if the type is already loaded.
    • onError

      public void onError(String typeName, @MaybeNull ClassLoader classLoader, @MaybeNull JavaModule module, boolean loaded, Throwable throwable)
      Invoked when an error has occurred during transformation.
      Specified by:
      onError in interface AgentBuilder.Listener
      Parameters:
      typeName - The binary name of the instrumented type.
      classLoader - The class loader which is loading this type or null if loaded by the boots loader.
      module - The instrumented type's module or null if the current VM does not support modules.
      loaded - true if the type is already loaded.
      throwable - The occurred error.
    • onComplete

      public void onComplete(String typeName, @MaybeNull ClassLoader classLoader, @MaybeNull JavaModule module, boolean loaded)
      Invoked after a class was attempted to be loaded, independently of its treatment.
      Specified by:
      onComplete in interface AgentBuilder.Listener
      Parameters:
      typeName - The binary name of the instrumented type.
      classLoader - The class loader which is loading this type or null if loaded by the boots loader.
      module - The instrumented type's module or null if the current VM does not support modules.
      loaded - true if the type is already loaded.