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

Misleading error message when superclass constructor has throws clause

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P5
    • Resolution: Fixed
    • Affects Version/s: 1.1.3
    • Fix Version/s: 1.4.2
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      mantis
    • CPU:
      generic
    • OS:
      solaris_7

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              gafter Neal Gafter
              Reporter:
              gafter Neal Gafter
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: