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

Throwing an inner class exception from subclass gives confusing error

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.2.0
    • tools
    • generic
    • generic



      Name: igT44549 Date: 02/08/99


      When attempting to throw an exception that is a protected inner
      class from a subclass of the outer class generates a confusing
      error:

      jx4\net\NetworkManager.java:119: No constructor matching
      Service. ShutdownRequiredException(jx4.net.NetworkManager) found
      in inner class jx4.sys.Service. ShutdownRequiredException.
            throw new ShutdownRequiredException();
                  ^
      1 error

      Note that this is probably also the case when instantiating
      a protected inner class in the same conditions.

      Example:

      package foo;

      public class OuterClass
      {
        protected class InnerException extends Exception
        {
        }
      }

      package bar;

      import foo.*;

      public class OtherOuterClass extends OuterClass
      {
        public void doSomething()
        {
          throw new InnerException();
        }
      }

      would generate an error like:

      bar\OtherOuterClass.java:123: No constructor matching
      OuterClass. InnerException(bar.OtherOuterClass) found
      in inner class foo.OuterClass. InnerException.
            throw new InnerExceptionException();
                  ^
      1 error
      (Review ID: 48516)
      ======================================================================

            wmaddoxsunw William Maddox (Inactive)
            iris Iris Clark
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: