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

IOException should have subclasses to better describe failure

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.1, 1.1.3, 1.1.4, 1.1.6
    • core-libs
    • generic, x86, sparc
    • generic, solaris_2.5.1, windows_nt

      Name: tb29552 Date: 09/15/97


       Trying to write to a write-protected file yields
       a FileNotFound exception. Looking at the source
       code, we see that an IOException is being caught
       and re-thrown as a FileNotFoundException.

       Therefore, we are losing the actual error (file
       can't be read) and gaining a bogus error (file can't
       be found). Since the original exception is lost,
       we don't know (without further work) whether the
       file doesn't exist or is just not writable.

       excerpting out of FileOutputStream.java <colon>

          public FileInputStream(String name) throws FileNotFoundException {
              SecurityManager security = System.getSecurityManager();
              if (security != null) {
                  security.checkRead(name);
              }
              try {
                  fd = new FileDescriptor();
                  open(name);
              } catch (IOException e) {
                  throw new FileNotFoundException(name);
              }
          }

       company - Integrated Measurement Systems , email - ###@###.###
      ======================================================================

            smarks Stuart Marks
            tbell Tim Bell
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: