From a68742200b2bca3a9a5ae5ac27e7d59db13fb71a Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 26 Oct 2009 11:44:29 -0600 Subject: [PATCH 1/3] return empty stack trace for thread which isn't running --- classpath/java/lang/Thread.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/classpath/java/lang/Thread.java b/classpath/java/lang/Thread.java index 2e494c850c..fec432b34e 100644 --- a/classpath/java/lang/Thread.java +++ b/classpath/java/lang/Thread.java @@ -186,7 +186,11 @@ public class Thread implements Runnable { } public StackTraceElement[] getStackTrace() { - return Throwable.resolveTrace(getStackTrace(peer)); + long p = peer; + if (p == 0) { + return new StackTraceElement[0]; + } + return Throwable.resolveTrace(getStackTrace(p)); } private static native Object getStackTrace(long peer); From 4570b86da0216eee49231754787b0e5d8aa74886 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 27 Oct 2009 09:16:08 -0600 Subject: [PATCH 2/3] add __attribute__ ((externally_visible)) to EXPORT macros to facilitate whole-program optimization using GCC 4.5 --- classpath/jni-util.h | 5 +++-- src/boot.cpp | 8 ++++---- src/common.h | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/classpath/jni-util.h b/classpath/jni-util.h index d144e704db..cbf33feda9 100644 --- a/classpath/jni-util.h +++ b/classpath/jni-util.h @@ -19,11 +19,12 @@ #if (defined __MINGW32__) || (defined _MSC_VER) # define PLATFORM_WINDOWS # define PATH_SEPARATOR ';' -# define JNIEXPORT __declspec(dllexport) +# define JNIEXPORT __declspec(dllexport) __attribute__ ((externally_visible)) #else # define PLATFORM_POSIX # define PATH_SEPARATOR ':' -# define JNIEXPORT __attribute__ ((visibility("default"))) +# define JNIEXPORT __attribute__ ((visibility("default"))) \ + __attribute__ ((externally_visible)) #endif #ifdef _MSC_VER diff --git a/src/boot.cpp b/src/boot.cpp index e313b6c553..c2980dc48e 100644 --- a/src/boot.cpp +++ b/src/boot.cpp @@ -27,10 +27,10 @@ extern "C" void __cxa_pure_virtual(void) { abort(); } #ifdef BOOT_IMAGE #if (defined __MINGW32__) || (defined _MSC_VER) -# define EXPORT __declspec(dllexport) +# define EXPORT __declspec(dllexport) __attribute__ ((externally_visible)) # define SYMBOL(x) binary_bootimage_bin_##x #else -# define EXPORT __attribute__ ((visibility("default"))) +# define EXPORT __attribute__ ((visibility("default"))) __attribute__ ((externally_visible)) # define SYMBOL(x) _binary_bootimage_bin_##x #endif @@ -53,10 +53,10 @@ extern "C" { #ifdef BOOT_CLASSPATH #if (defined __MINGW32__) || (defined _MSC_VER) -# define EXPORT __declspec(dllexport) +# define EXPORT __declspec(dllexport) __attribute__ ((externally_visible)) # define SYMBOL(x) binary_classpath_jar_##x #else -# define EXPORT __attribute__ ((visibility("default"))) +# define EXPORT __attribute__ ((visibility("default"))) __attribute__ ((externally_visible)) # define SYMBOL(x) _binary_classpath_jar_##x #endif diff --git a/src/common.h b/src/common.h index 7c92f85f2c..7b67a14fe5 100644 --- a/src/common.h +++ b/src/common.h @@ -90,10 +90,10 @@ typedef uint64_t uintptr_t; #undef JNIEXPORT #ifdef PLATFORM_WINDOWS -# define JNIEXPORT __declspec(dllexport) +# define JNIEXPORT __declspec(dllexport) __attribute__ ((externally_visible)) # define PATH_SEPARATOR ';' #else -# define JNIEXPORT __attribute__ ((visibility("default"))) +# define JNIEXPORT __attribute__ ((visibility("default"))) __attribute__ ((externally_visible)) # define PATH_SEPARATOR ':' #endif From b15ff58542a23123c8d9c95436825fb2455bdf0a Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 27 Oct 2009 09:17:08 -0600 Subject: [PATCH 3/3] provide a useful error message when throwing IOExceptions from Java_java_nio_channels_SocketChannel_natFinishConnect --- classpath/java-nio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classpath/java-nio.cpp b/classpath/java-nio.cpp index a7046f8957..66904a26ca 100644 --- a/classpath/java-nio.cpp +++ b/classpath/java-nio.cpp @@ -397,7 +397,7 @@ Java_java_nio_channels_SocketChannel_natFinishConnect(JNIEnv *e, } else if (einProgress(error)) { return false; } else if (error != 0) { - throwIOException(e); + throwIOException(e, errorString(e, error)); } return true; }