Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8036958

doc, release notes for JDK-8036942 should be added

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 8
    • 8
    • docs

      For a code like:

      import java.io.IOException;

      class LambdaWithMultiCatch {
          public static void main(String[] args) {
              Runnable r = () -> {
              try {
                  throw new IOException();
              } catch(IOException | IllegalArgumentException e) {
                  System.out.println("This code will generate a wrong exception table");
              }
            };
            r.run();
          }
      }

      javac will generate an incorrect exception table for method main. The generated exception table will look like:

          Exception table:
               from to target type
                   0 8 8 Class java/lang/Exception <---- no trace of IOException nor IllegalArgumentException

      This is a known issue and developers should avoid using multi-catch statements inside lambda bodies till this issue is fixed.

            jgordon Joni Gordon (Inactive)
            vromero Vicente Arturo Romero Zaldivar
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: