Annotation Type FFDCIgnore


@Retention(CLASS) @Target({METHOD,CONSTRUCTOR}) public @interface FFDCIgnore
Indicate which catch blocks should not be instrumented for FFDC. This annotation should be added to methods that contain catch blocks for exceptions that are part of the normal execution.

The exception classes called out in the annotation must match the exception type declared on the catch block. The filtering is not based on the runtime type of the exception class but on the statically declared types in the code.

For example:

 @FFDCIgnore({ RuntimeException.class, MyException2.class })
 public void doSomeWork() {
     try {
         someMethod();
     } catch (MyException e) {
         // This block will have FFDC instrumentation added
     } catch (MyException2 e) {
         // This block will not
     } catch (RuntimeException e) {
         // This block will not either
     } catch (Throwable e) {
         // This block will have FFDC instrumentation added
     }
 }
 

Multi-catch blocks

For a multi-catch block, the last exception in the multi-catch should be listed in @FFDCIgnore.

 @FFDCIgnore(InvalidStateException.class)
 public void doSomeWork() {
     try {
         someMethod();
     } catch (IOException | InvalidStateException e) {
         // This block will not have FFDC instrumentation added
     } catch (Exception e) {
         // This block will have FFDC instrumentation added
     }
 }
 

try-with-resources limitation

When using the try-with-resources construction, the compiler will generate several catch (Throwable) blocks and the FFDC instrumentation cannot currently tell these apart from catch blocks which are actually in the code.

Therefore, when using try-with-resources, you currently need to add @FFDCIgnore(Throwable.class) to avoid having these extra catch blocks instrumented.

 @FFDCIgnore(Throwable.class)
 public void readSomeFile(File file) {
     try (InputStream is = new FileInputStream(file)) {
        // Read the file here
     }
 }
 
See issue 22396 for the issue for this limitation

See JLS 14.20.3.1 for more information about the equivalent code generated for a try-with-resources statement.

  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Class<?>[]
     
  • Element Details

    • value

      Class<?>[] value