Annotation Type Advice.OnMethodExit


  • @Documented
    @Retention(RUNTIME)
    @Target(METHOD)
    public static @interface Advice.OnMethodExit

    Indicates that this method should be executed before exiting the instrumented method. Any class must declare at most one method with this annotation. The annotated method must be static.

    By default, the annotated method is not invoked if the instrumented method terminates exceptionally. This behavior can be changed by setting the onThrowable() property to an exception type for which this advice method should be invoked. By setting the value to Throwable, the advice method is always invoked.

    See Also:
    Advice, Advice.Argument, Advice.This, Advice.Enter, Advice.Return, Advice.Thrown
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean inline
      Determines if the annotated method should be inlined into the instrumented method or invoked from it.
      java.lang.Class<? extends java.lang.Throwable> onThrowable
      Indicates a Throwable super type for which this exit advice is invoked if it was thrown from the instrumented method.
      java.lang.Class<? extends java.lang.Throwable> suppress
      Indicates that this advice should suppress any Throwable type being thrown during the advice's execution.
    • Element Detail

      • onThrowable

        java.lang.Class<? extends java.lang.Throwable> onThrowable
        Indicates a Throwable super type for which this exit advice is invoked if it was thrown from the instrumented method. If an exception is thrown, it is available via the Advice.Thrown parameter annotation. If a method returns exceptionally, any parameter annotated with Advice.Return is assigned the parameter type's default value.
        Returns:
        The type of Throwable for which this exit advice handler is invoked.
        Default:
        net.bytebuddy.asm.Advice.NoExceptionHandler.class
      • inline

        boolean inline
        Determines if the annotated method should be inlined into the instrumented method or invoked from it. When a method is inlined, its byte code is copied into the body of the target method. this makes it is possible to execute code with the visibility privileges of the instrumented method while loosing the privileges of the declared method methods. When a method is not inlined, it is invoked similarly to a common Java method call. Note that it is not possible to set breakpoints within a method when it is inlined as no debugging information is copied from the advice method into the instrumented method.
        Returns:
        true if the annotated method should be inlined into the instrumented method.
        Default:
        true
      • suppress

        java.lang.Class<? extends java.lang.Throwable> suppress
        Indicates that this advice should suppress any Throwable type being thrown during the advice's execution. By default, any such exception is silently suppressed. Custom behavior can be configured by using Advice.withExceptionHandler(StackManipulation).
        Returns:
        The type of Throwable to suppress.
        See Also:
        Advice.withExceptionPrinting()
        Default:
        net.bytebuddy.asm.Advice.NoExceptionHandler.class