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

close method throws IOException in 1.2 but not in 1.1

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.1.8
    • core-libs
    • generic
    • generic



      Name: vi73552 Date: 04/25/99


      java.io.Writer: abstract method close throws IO Exception
       (1.1 and 1.2)
      java.io.StreamWriter: overriden method close throws IO Exception
        in 1.2, but not in 1.1.
        As a result, the following code is ok under 1.2, but not under
        1.1 (8):

      ---------------------------------
      import java.io.*;

      public class IO
      {
        public void nothing()
        { try { StringWriter w=new StringWriter();
                w.close();
              }
          catch (IOException e) {}
        }
      }
      --------------------------------------------

      whereas the other way around, the following code:


      import java.io.*;

      public class IO
      {
        public void nothing()
        { // try {
                StringWriter w=new StringWriter();
                w.close();
          // }
          // catch (IOException e) {}
        }
      }

      is ok in 1.1.8, but not in 1.2!

      ------------------------------------

      This causes quite a bit of problem in code refinement.

      Actually, this is related to a deeper problem in the
      Java specification, clarification would be useful!

      If an abstract method is declared to throw an exception,
      has a overriding method to throw the same exception?
      (Review ID: 56855)
      ======================================================================

            Unassigned Unassigned
            vasya Vassili Igouchkine (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: