diff -r 773449708c84 -r 4ad59aaee882 javacommons/utils/src/debugutils.cpp --- a/javacommons/utils/src/debugutils.cpp Thu Sep 02 20:20:40 2010 +0300 +++ b/javacommons/utils/src/debugutils.cpp Fri Sep 17 08:28:21 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); + } + } +}