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

multiple-catch statement behaves strangely

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.6
    • 2.5.6, 3.0.0-beta-1
    • groovy-runtime
    • None
    • Windows 10

    Description

      try {
          throw new AnyJavaException()
      } catch ( AnyJavaException1 | AnyJavaException2 e ) {
          println e.message
      }
      

      This works as expected. But following does not:

      try {
          throw new AnyJavaException()
      } catch ( AnyJavaException | AnyGroovyException e ) {
          println e.message
      }
      

      You get:

      java.lang.ClassCastException: AnyJavaException cannot be cast to groovy.lang.GroovyObject
      

      Attachments

        Activity

          People

            paulk Paul King
            GertG Gert Grossmann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: