[Bug java/18376] New: java.io.BufferedWriter outputing extraneous characters?

wayne dot gray at coynetextileservices dot com gcc-bugzilla@gcc.gnu.org
Mon Nov 8 14:57:00 GMT 2004


Version:  gcj 3.4.0 20040316 on Windows 2000 (mingw)

The below copy file function works in Sun's 1.4.1_01 JVM but with GCJ the output
has tons of whitespace added.

I have a complete test set up but am unsure how to attach files to this report.
 If you need more info then please give me instructions on how to get them to
you. Thanks.

package TestGcj;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;


public class IoTest {

	/**
	 * 
	 */
	public IoTest() {
		super();
		// TODO Auto-generated constructor stub
	}
	
	public static void main(String[] args){
		try 
		{
			copyFile2(args[0], args[1]);
		} catch (Exception e){
			e.printStackTrace();
		}
	}
	
	public static void copyFile2(String src, String dest) throws IOException{
		String newLine = System.getProperty("line.separator"); 
		FileWriter fw = null; 
		FileReader fr = null; 
		BufferedReader br = null; 
		BufferedWriter bw = null; 
		File source = null; 

 
		try { 
		fr = new FileReader(src); 
		fw = new FileWriter(dest); 
		br = new BufferedReader(fr); 
		bw = new BufferedWriter(fw); 

		/* Determine the size of the buffer to allocate */ 
		source = new File(src); 

		int fileLength = (int) source.length(); 

		char charBuff[] = new char[fileLength]; 

		while (br.read(charBuff,0,fileLength) != -1) 
		bw.write(charBuff,0,fileLength); 
		  } 
		catch(FileNotFoundException fnfe){ 
			System.out.println(src + " does not exist!");
			return;
		} 
		catch(IOException ioe) { 
			System.out.println("Error reading/writing files!");
			return;
		} 
		finally { 
			try { 
				if (br != null) 
				br.close(); 

				if (bw != null) 
					bw.close(); 
				} 
			catch(IOException ioe) 
			{} 
		} 
 	}

}

Build Output:

Buildfile: build.xml

build:
    [mkdir] Created dir: C:\TEMP\jtracetest\TestGcj\out
     [copy] Copied 1 empty directory to 1 empty directory under
C:\TEMP\jtracetest\TestGcj\out
    [apply] Reading specs from C:/gcc-3.4/bin/../lib/gcc/i686-pc-mingw32/3.4.0/specs
    [apply] Reading specs from
C:/gcc-3.4/bin/../lib/gcc/i686-pc-mingw32/3.4.0/../../../../i686-pc-mingw32/lib/libgcj.spec
    [apply] rename spec lib to liborig
    [apply] Configured with: /datal/gcc/gcc/configure
--prefix=/datal/gcc/build/wingcc --build=i686-pc-linux-gnu
--host=i686-pc-mingw32 --target=i686-pc-mingw32 --enable-languages=c,c++,java
--with-gcc --with-gnu-as --with-gnu-ld --with-as=i686-pc-mingw32-as
--with-ld=i686-pc-mingw32-ld --enable-threads=win32 --disable-nls
--disable-win32-registry --disable-shared --disable-debug --without-newlib
--enable-libgcj --disable-java-awt --without-x --enable-java-gc=boehm
--disable-libgcj-debug --enable-interpreter --enable-hash-synchronization
--enable-sjlj-exceptions --enable-libgcj-multifile --enable-libgcj-mingw-osapi=ansi
    [apply] Thread model: win32
    [apply] gcc version 3.4.0 20040316 (prerelease)
    [apply]  C:/gcc-3.4/bin/../libexec/gcc/i686-pc-mingw32/3.4.0/jc1.exe
C:\TEMP\jtracetest\TestGcj\src\TestGcj\IoTest.java -fhash-synchronization
-fuse-divide-subroutine -fcheck-references -fuse-boehm-gc -fnon-call-exceptions
-fkeep-inline-functions -quiet -dumpbase IoTest.java -mtune=pentiumpro
-auxbase-strip C:\TEMP\jtracetest\TestGcj\out\TestGcj\IoTest.o -g -O -Wall
-version -fCLASSPATH=C:\TEMP\jtracetest\TestGcj/src/ -o
C:\DOCUME~1\WGGRAY\LOCALS~1\Temp/ccCwaaaa.s
    [apply] GNU Java version 3.4.0 20040316 (prerelease) (i686-pc-mingw32)
    [apply] 	compiled by GNU C version 3.4.0 20040316 (prerelease).
    [apply] GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=65279
    [apply] Class path starts here:
    [apply]     C:\TEMP\jtracetest\TestGcj/src/
    [apply]     C:\gcc-3.4\bin/../lib/gcc/../../share/java/libgcj-3.4.0.jar/
(system) (zip)
    [apply] 
C:/gcc-3.4/bin/../lib/gcc/i686-pc-mingw32/3.4.0/../../../../i686-pc-mingw32/bin/as.exe
-o C:\TEMP\jtracetest\TestGcj\out\TestGcj\IoTest.o
C:\DOCUME~1\WGGRAY\LOCALS~1\Temp/ccCwaaaa.s



link:



BUILD SUCCESSFUL
Total time: 2 seconds

-- 
           Summary:  java.io.BufferedWriter outputing  extraneous
                    characters?
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wayne dot gray at coynetextileservices dot com
                CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
                    dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18376



More information about the Gcc-bugs mailing list