--- a/javacommons/utils/src/debugutils.cpp Mon Aug 23 14:24:31 2010 +0300
+++ b/javacommons/utils/src/debugutils.cpp Thu Sep 02 13:22:59 2010 +0300
@@ -39,3 +39,28 @@
ThreadDump::closeDumper();
}
+/**
+ * A utility for getting the stack trace for further processing.
+ * @param th The throwable from where the stack trace should be get.
+ * @param printStream Where to print the stack trace.
+ */
+JNIEXPORT void JNICALL
+Java_com_nokia_mj_impl_utils_DebugUtils__1getStackTrace
+(JNIEnv* jniEnv, jclass, jthrowable th, jobject printStream)
+{
+ /*
+ * call Throwable.printStackTrace(java.io.PrintStream)
+ * this method is not part of CLDC spec, but it's supported by VM vendor.
+ */
+ jclass classThrowable = jniEnv->GetObjectClass(th);
+ if (classThrowable)
+ {
+ jmethodID methodId = jniEnv->GetMethodID(classThrowable,
+ "printStackTrace",
+ "(Ljava/io/PrintStream;)V");
+ if (methodId)
+ {
+ jniEnv->CallVoidMethod(th, methodId, printStream);
+ }
+ }
+}