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

Misleading error message when superclass constructor has throws clause

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 1.1.3
    • tools
    • sparc
    • solaris_2.5.1



      Name: tb29552 Date: 08/12/97


      The following program

      > package bug;
      >
      > class SuperClass
      > {
      > SuperClass() throws Exception { throw new Exception(); }
      > }
      >
      > public class Bug extends SuperClass
      > {
      > // Comment in the following line to make javac compile.
      > // Bug() throws Exception {}
      > }

      leads to the following error message:

      > bug/Bug.java:8: unreported exception: Exception; must be caught or
      declared to be thrown
      > public class Bug extends SuperClass
      > ^
      > 1 error

      Ok, class Bug must define a constructor that
      throws the same exception as the superclass
      constructor does; then the program compiles.
      But the error message is quite misleading, if you
      do not recognize the problem.

      company - University of Karlsruhe, Germany , email - ###@###.###
      ======================================================================

            gafter Neal Gafter (Inactive)
            tbell Tim Bell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: