public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* libgcj/1298: PrintWriter methods badly implemented
@ 2000-12-20 12:24 osk
  0 siblings, 0 replies; only message in thread
From: osk @ 2000-12-20 12:24 UTC (permalink / raw)
  To: java-gnats

>Number:         1298
>Category:       libgcj
>Synopsis:       PrintWriter methods badly implemented
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    tromey
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 20 12:18:50 PST 2000
>Closed-Date:    Mon Jul 03 14:04:34 PDT 2000
>Last-Modified:  Mon Jul  3 14:16:00 PDT 2000
>Originator:     Oskar Liljeblad
>Release:        unknown-1.0
>Organization:
>Environment:
Debian GNU/Linux
GNU libc 2.1.3
gcc 2.96 snapshot 20000612
libgcj snapshot 2000-06-18
>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). Currently,
PrintWriter.print(Object obj) calls PrintWriter.print(String str).
The same applies to all other PrintWriter.print methods.

Oskar Liljeblad (osk@hem.passagen.se)
>How-To-Repeat:

>Fix:

>Release-Note:

>Audit-Trail:

Formerly PR libgcj/277


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 ]
 
 

From: Tom Tromey <tromey@cygnus.com>
To: Java Gnats Server <java-gnats@sourceware.cygnus.com>
Cc:  
Subject: libgcj/277
Date: 03 Jul 2000 14:32:10 -0600

 I looked into this a bit more.
 
 Consider the appended Java program.
 
 This runs differently under Sun's JDK 1.2 and gij.
 
     creche. java pw
     zardoz has spokenfnord!
 
     23
     creche. gij pw
     zardoz has spokenfnord!
 
     23fnord!
     
     creche.
 
 I think the fix is to change print() methods in PrintStreamWriter to
 call write(String) and not print(String).
 
 If, in the appended program, I change the print method to `write' and
 change its implementation to call `super.write' then I get this:
 
     creche. java pw
     zardoz has spokenfnord!
 
     23fnord!
 
     creche. gij pw
     zardoz has spoken
     23
     creche. 
 
 So, I'm going to submit a fix for this.
 
 Tom
 
 import java.io.*;
 public class pw extends PrintWriter
 {
   public pw (OutputStream o)
   {
     super (o);
   }
 
   public void print (String z)
   {
     super.print(z);
     super.print("fnord!\n");
   }
 
   public static void main (String[] args)
   {
     pw z = new pw (System.out);
     z.println ("zardoz has spoken");
     z.println (23);
     z.flush();
   }
 }
State-Changed-From-To: open->closed
State-Changed-By: tromey
State-Changed-When: Mon Jul  3 14:04:34 2000
State-Changed-Why:
    I've checked in a fix for what I see as the real
    problem here.  Our PrintWriter is now compatible with
    the implementation in JDK 1.2.2
    If you still think this is wrong, we can reopen the
    PR and discuss it.

From: tromey@sourceware.cygnus.com
To: java-gnats@sourceware.cygnus.com
Cc:  
Subject: libgcj/277
Date: 3 Jul 2000 21:03:52 -0000

 CVSROOT:	/cvs/java
 Module name:	libgcj
 Changes by:	tromey@sourceware.cygnus.com	00/07/03 14:03:52
 
 Modified files:
 	libjava        : ChangeLog 
 	libjava/java/io: PrintWriter.java 
 
 Log message:
 	* java/io/PrintWriter.java (print): Call write(String), not
 	print(String).  See PR libgcj/277.
 	(print(String)): Use write, not out.write.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/gcc/libjava/ChangeLog.diff?cvsroot=java&r1=1.409&r2=1.410
 http://gcc.gnu.org/cgi-bin/gcc/libjava/java/io/PrintWriter.java.diff?cvsroot=java&r1=1.3&r2=1.4
 

From: tromey@cygnus.com
To: java-gnats@sourceware.cygnus.com, osk@hem.passagen.se, tromey@cygnus.com
Cc:  
Subject: Re: libgcj/277
Date: 3 Jul 2000 21:04:34 -0000

 Synopsis: PrintWriter methods badly implemented
 
 State-Changed-From-To: open->closed
 State-Changed-By: tromey
 State-Changed-When: Mon Jul  3 14:04:34 2000
 State-Changed-Why:
     I've checked in a fix for what I see as the real
     problem here.  Our PrintWriter is now compatible with
     the implementation in JDK 1.2.2
     If you still think this is wrong, we can reopen the
     PR and discuss it.
 
 http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?cmd=view&pr=277&database=java
>Unformatted:



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2000-12-20 12:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-12-20 12:24 libgcj/1298: PrintWriter methods badly implemented osk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).