From 16aa5c3d59e4da09bc46718f545c70c7a2d68a03 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Mon, 15 Aug 2011 07:12:52 -0600 Subject: [PATCH 1/3] improve IOException message in the case of a Runtime.exec() failure We now properly forward the errno value from the child when execvp() fails, which the parent then uses to for the errno message as well as including the failed command's name in the message. --- classpath/java-lang.cpp | 9 +++++---- classpath/java/lang/Runtime.java | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/classpath/java-lang.cpp b/classpath/java-lang.cpp index 49aebbca32..4f301572e9 100644 --- a/classpath/java-lang.cpp +++ b/classpath/java-lang.cpp @@ -411,8 +411,8 @@ Java_java_lang_Runtime_exec(JNIEnv* e, jclass, execvp(argv[0], argv); // Error if here - char c = errno; - ssize_t rv UNUSED = write(msg[1], &c, 1); + int val = errno; + ssize_t rv UNUSED = write(msg[1], &val, sizeof(val)); exit(127); } break; @@ -425,12 +425,13 @@ Java_java_lang_Runtime_exec(JNIEnv* e, jclass, safeClose(err[1]); safeClose(msg[1]); - char c; - int r = read(msg[0], &c, 1); + int val; + int r = read(msg[0], &val, sizeof(val)); if(r == -1) { throwNewErrno(e, "java/io/IOException"); return; } else if(r) { + errno = val; throwNewErrno(e, "java/io/IOException"); return; } diff --git a/classpath/java/lang/Runtime.java b/classpath/java/lang/Runtime.java index 30dc0b6612..a24f850bf3 100644 --- a/classpath/java/lang/Runtime.java +++ b/classpath/java/lang/Runtime.java @@ -103,7 +103,8 @@ public class Runtime { if (exception[0] != null) { if (exception[0] instanceof IOException) { - throw new IOException(exception[0]); + String message = "Failed to run \"" + command[0] + "\": " + exception[0].getMessage(); + throw new IOException(message); } else { throw new RuntimeException(exception[0]); } From d09e5ee8ebb5b9c75a5fdae380cba7739c93b081 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 15 Aug 2011 16:37:15 -0600 Subject: [PATCH 2/3] fix Windows build regression --- classpath/java-io.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classpath/java-io.cpp b/classpath/java-io.cpp index 6fa22bf359..9bcfa88afd 100644 --- a/classpath/java-io.cpp +++ b/classpath/java-io.cpp @@ -314,7 +314,7 @@ Java_java_io_File_toCanonicalPath(JNIEnv* /*e*/, jclass, jstring path) } extern "C" JNIEXPORT jstring JNICALL -Java_java_io_File_toAbsolutePath(JNIEnv* e, jclass, jstring path) +Java_java_io_File_toAbsolutePath(JNIEnv* e UNUSED, jclass, jstring path) { #ifdef PLATFORM_WINDOWS // todo From 9522842b4b304679e2297814ef723e43fd915203 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 23 Aug 2011 17:04:04 -0600 Subject: [PATCH 3/3] support cross builds on OS X to non-Mac targets --- makefile | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/makefile b/makefile index 3474de80f0..281f263229 100755 --- a/makefile +++ b/makefile @@ -229,7 +229,7 @@ endif ifeq ($(arch),arm) asm = arm pointer-size = 4 - ifneq ($(platform),darwin) + ifneq ($(build-platform),darwin) cflags += -marm -Wno-psabi endif @@ -251,6 +251,12 @@ ifeq ($(arch),arm) endif endif +ifeq ($(build-platform),darwin) + build-cflags = $(common-cflags) -fPIC -fvisibility=hidden -I$(src) + cflags += -I/System/Library/Frameworks/JavaVM.framework/Headers/ + build-lflags += -framework CoreFoundation +endif + ifeq ($(platform),darwin) ifeq (${OSX_SDK_SYSROOT},) OSX_SDK_SYSROOT = 10.4u @@ -267,10 +273,6 @@ ifeq ($(platform),darwin) sysroot = /opt/mac/SDKs/MacOSX${OSX_SDK_SYSROOT}.sdk cflags = -I$(sysroot)/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Headers/ \ $(common-cflags) -fPIC -fvisibility=hidden -I$(src) - else - build-cflags = $(common-cflags) -fPIC -fvisibility=hidden -I$(src) - cflags += -I/System/Library/Frameworks/JavaVM.framework/Headers/ - build-lflags += -framework CoreFoundation endif version-script-flag = @@ -555,6 +557,9 @@ else -DAVIAN_CLASSPATH=\"[classpathJar]\" endif +cflags += $(extra-cflags) +lflags += $(extra-lflags) + driver-source = $(src)/main.cpp driver-object = $(build)/main.o driver-dynamic-objects = \