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

ClassCastException calling super(String) of java.lang.Exception

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-JSR-2
    • 1.0-RC-1
    • None
    • None
    • WinXP

    Description

      I have build a subclass of java.lang.Exception which calls the super constructor of Exception with a String parameter.
      When instanciating the class I get an class cast error.

      class ExceptionSubclass extends Exception {
      ExceptionSubclass(String s)

      { super(s) }
      public static void main(String[] args) { println new ExceptionSubclass("s") }
      }

      I get the error: Caught: java.lang.ClassCastException: java.lang.String


      If I create a java helper class which is a subclass of Exception everything works find:

      public class JavaException extends Exception { //Java
      public JavaException(String s) { super(s);}
      }

      class ExceptionSubclass extends JavaException { // Groovy
      ExceptionSubclass(String s) { super(s) }

      public static void main(String[] args)

      { println new ExceptionSubclass("s") }

      }

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            tof Christof Vollrath
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: