Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-6411

Incorrect exception behavior when class has @CompileStatic

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.8
    • Fix Version/s: 2.2.1
    • Component/s: Static compilation
    • Labels:
      None

      Description

      import groovy.transform.CompileStatic
      
      @CompileStatic
      class Client<T> {
        static String method() {
          return ({
            try {
              return doSomething()
            } catch (IOException ioe) {
              println "IOException: ${ioe}"
            } catch (Exception e) {
              println "Exception: ${e}"
            }
          })()
        }
      
        private static <T> T doSomething() throws IOException {
          throw new IOException()
          return null
        }
      }
      
      Client.method()
      

      Without the @CompileStatic, it outputs (as expected)

      IOException: java.io.IOException
      

      With the @CompileStatic, it outputs

      Exception: org.codehaus.groovy.runtime.InvokerInvocationException: java.io.IOException
      

        Attachments

          Activity

            People

            • Assignee:
              melix C├ędric Champeau
              Reporter:
              acourtneybrown Adam Brown
            • Votes:
              5 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: