libgcj/277: PrintWriter methods badly implemented
Bryce McKinlay
bryce@albatross.co.nz
Sat Jul 1 23:50:00 GMT 2000
The following reply was made to PR libgcj/277; it has been noted by GNATS.
From: Bryce McKinlay <bryce@albatross.co.nz>
To: osk@hem.passagen.se
Cc: java-gnats@sourceware.cygnus.com
Subject: Re: libgcj/277: PrintWriter methods badly implemented
Date: Sun, 02 Jul 2000 18:46:51 +1200
osk@hem.passagen.se wrote:
> >Description:
> Many of the methods in the PrintWriter class are badly implemented.
> According to the Sun javadocs, PrintWriter.print(Object obj) should
> use String.valueOf(Object) then write(int).
As far as I can tell, it doesn't actually say that. The javadoc for
PrintWriter.print(Object) in J2SE 1.3 says:
"these bytes are written in exactly the manner of the write(int)
method."
I agree that the current implementation isn't very good, though -
calling print() means there is a redundant check for String==null. I
took a look at the classpath implementation and it is basically the same
as libgcj.
I suspect what this statement means is that the print() methods do
exactly the same as what write() does, but don't actually call write().
write() is a public method so there is some benefit in inlining it (or
replacing it with a private method that will be inlined by the
compiler) given that print() is so frequently called.
regards
[ bryce ]
More information about the Java-prs
mailing list