On Mon, 2007-10-15 at 07:28 -0700, Anthony Green wrote:
Andrew Haley wrote:
> The PrintWriter.append methods in OpenJDK don't either.
> PrintWriter.append(c) calls out.write(c), which catches IOException
> and doesn't re-throw it.
> > Is this a bug?
> IMO no.
So it's a compiler bug? Something must be wrong somewhere...
I suspect this is a 1.4/1.5 issue. PrintWriter extends Writer which
implements Appendable in 1.5 which is has return type Appendable (which
means Writer in Writer itself). Which means that it has a covariant
return type. In the case of PrintWriter there are actually 3 methods,
one that returns type PrintWriter and two "invisible" bridge methods
with return types Appendable and Writer. If you look with jcf-dump you
will notice that the bridge method does throw the IOException, while the
variant that returns an Appendable doesn't. The compiler, in 1.4
compatibility mode, doesn't know about covariant return types and checks
your code against the wrong variant.
Bottom line, your source code is not compatible with the 1.5 core
classes (the change is binary compatible though, so if you don't
recompile things should work - which I expect isn't an option for a
Fedora package). You might have to compile with an explicit -1.5 to get
the compiler to handle the bridge methods correctly and pretend your
code is 1.5 source code (hoping that doesn't trigger some other source