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

multiple-catch statement behaves strangely

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.6
    • Fix Version/s: 2.5.6, 3.0.0-beta-1
    • Component/s: groovy-runtime
    • Labels:
      None
    • Environment:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: