Annotation Interface Advice.Thrown

Enclosing class:
Advice

@Documented @Retention(RUNTIME) @Target(PARAMETER) public static @interface Advice.Thrown

Indicates that the annotated parameter should be mapped to the Throwable thrown by the instrumented method or to null if the method returned regularly. Note that the Java runtime does not enforce checked exceptions. In order to capture any error, the parameter type must therefore be of type Throwable. By assigning another value or null to this parameter, a thrown exception can be suppressed.

Note: This annotation must only be used on Advice.OnMethodExit advice methods.

See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Indicates if it is possible to write to this parameter.
    Determines the typing that is applied when assigning the captured Throwable to the annotated parameter.
  • Element Details

    • readOnly

      boolean readOnly

      Indicates if it is possible to write to this parameter. If this property is set to false, the annotated type must be equal to the type declaring the instrumented method if the typing is not also set to Assigner.Typing.DYNAMIC. If this property is set to true, the annotated parameter can be any super type of the instrumented method's declaring type.

      Important: This property must be set to true if the advice method is not inlined.

      Returns:
      true if this parameter is read-only.
      Default:
      true
    • typing

      Determines the typing that is applied when assigning the captured Throwable to the annotated parameter.
      Returns:
      The typing to apply when assigning the annotated parameter.
      Default:
      DYNAMIC