This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] ecj1 always fails with OpenJDK runtime.


When ecj1 is run using the OpenJDK runtime, gcj -C always exits with a failure exit code (1) even though no diagnostics are issued.

I tracked the problem down to a difference in behavior between the libgcj and OpenJDK for java.util.ZipOutputStream. org/eclipse/jdt/internal/compiler/batch/GCCMain tries to create a zip stream with no files. This succeeds under libgcj but fails under OpenJDK

My hackish fix is to always create an empty file named '.dummy' in the stream. I don't know if this is completely safe, but it does allow me to successfully do a --enable-java-maintainer-mode build.

2009-03-26 David Daney <ddaney@caviumnetworks.com>

	* org/eclipse/jdt/internal/compiler/batch/GCCMain.java (fail):
	print a stack trace.
	(getZipOutput,getDependencyOutput): Create an empty dummy entry.
diff -rup ../ecj-clean/org/eclipse/jdt/internal/compiler/batch/GCCMain.java org/eclipse/jdt/internal/compiler/batch/GCCMain.java
--- ../ecj-clean/org/eclipse/jdt/internal/compiler/batch/GCCMain.java	2007-07-26 22:29:40.000000000 -0700
+++ org/eclipse/jdt/internal/compiler/batch/GCCMain.java	2009-03-26 09:05:30.000000000 -0700
@@ -71,6 +71,7 @@ public class GCCMain extends Main {
 	}
 
 	private void fail(Exception t) {
+		t.printStackTrace();
 		this.logger.logException(t);
 		System.exit(1);
 	}
@@ -99,6 +100,16 @@ public class GCCMain extends Main {
 			}
 			zipStream = new ZipOutputStream(new BufferedOutputStream(os));
 			zipStream.setMethod(ZipOutputStream.STORED);
+			// Sun/OpenJDK require at least one entry in the zip file.
+			ZipEntry entry = new ZipEntry(".dummy");
+			byte[] contents = new byte[0];
+			CRC32 crc = new CRC32();
+			crc.update(contents);
+			entry.setSize(contents.length);
+			entry.setCrc(crc.getValue());
+			zipStream.putNextEntry(entry);
+			zipStream.write(contents);
+			zipStream.closeEntry();
 		}
 		return zipStream;
 	}
@@ -108,6 +119,16 @@ public class GCCMain extends Main {
 			OutputStream os = new FileOutputStream(zipDependencyDestination);
 			zipDependencyStream = new ZipOutputStream(new BufferedOutputStream(os));
 			zipDependencyStream.setMethod(ZipOutputStream.STORED);
+			// Sun/OpenJDK require at least one entry in the zip file.
+			ZipEntry entry = new ZipEntry(".dummy");
+			byte[] contents = new byte[0];
+			CRC32 crc = new CRC32();
+			crc.update(contents);
+			entry.setSize(contents.length);
+			entry.setCrc(crc.getValue());
+			zipDependencyStream.putNextEntry(entry);
+			zipDependencyStream.write(contents);
+			zipDependencyStream.closeEntry();
 		}
 		return zipDependencyStream;
 	}
Only in org/eclipse/jdt/internal/compiler/batch: GCCMain.java.~1.4.~

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]