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)
======================================================================
- relates to
-
JDK-4153007 java.io.ByteArrayOutputStream allows writes after close
-
- Resolved
-