summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules/java/eval.hpp
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-02-07 20:19:23 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-02-07 20:19:23 +0000
commit6b7a8a38f609117572820711638508a23ad57850 (patch)
treecfd15ced8363fa5163cbf874ec01178254169fbf /sca-cpp/trunk/modules/java/eval.hpp
parent9f67144615b018828226949701a6935336cbfc43 (diff)
Support HTTPD graceful restarts for non-stop operation. Simplified Python and Java error capture and recovery.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@907470 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-cpp/trunk/modules/java/eval.hpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/sca-cpp/trunk/modules/java/eval.hpp b/sca-cpp/trunk/modules/java/eval.hpp
index e10ec29a0b..9140fe75b4 100644
--- a/sca-cpp/trunk/modules/java/eval.hpp
+++ b/sca-cpp/trunk/modules/java/eval.hpp
@@ -29,13 +29,12 @@
#include "list.hpp"
#include "value.hpp"
-#include "io.hpp"
namespace tuscany {
namespace java {
/**
- * Initialize a JVM.
+ * Represent a Java VM runtime.
*/
jobject JNICALL nativeInvoke(JNIEnv *env, jobject self, jobject proxy, jobject method, jobjectArray args);
@@ -87,9 +86,6 @@ public:
jvm->GetEnv((void**)&env, JNI_VERSION_1_6);
}
- // Capture JVM standard IO
- setupIO();
-
// Lookup System classes and methods
classClass = env->FindClass("java/lang/Class");
methodClass = env->FindClass("java/lang/reflect/Method");
@@ -114,6 +110,7 @@ public:
loaderForName = env->GetStaticMethodID(loaderClass, "forName", "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;");
invokerClass = env->FindClass("org/apache/tuscany/InvocationHandler");
invokerValueOf = env->GetStaticMethodID(invokerClass, "valueOf", "(Ljava/lang/Class;J)Ljava/lang/Object;");
+ invokerStackTrace = env->GetStaticMethodID(invokerClass, "stackTrace", "(Ljava/lang/Throwable;)Ljava/lang/String;");
invokerLambda = env->GetFieldID(invokerClass, "lambda", "J");
iterableUtilClass = env->FindClass("org/apache/tuscany/IterableUtil");
iterableValueOf = env->GetStaticMethodID(iterableUtilClass, "list", "([Ljava/lang/Object;)Ljava/lang/Iterable;");
@@ -127,7 +124,6 @@ public:
nm.signature = const_cast<char*>("(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;");
nm.fnPtr = (void*)nativeInvoke;
env->RegisterNatives(invokerClass, &nm, 1);
-
}
JavaVM* jvm;
@@ -154,13 +150,13 @@ public:
jmethodID loaderForName;
jclass invokerClass;
jmethodID invokerValueOf;
+ jmethodID invokerStackTrace;
jfieldID invokerLambda;
jclass iterableUtilClass;
jmethodID iterableValueOf;
jmethodID iterableCar;
jmethodID iterableCdr;
jmethodID iterableIsNil;
-
};
/**
@@ -169,9 +165,13 @@ public:
string lastException(const JavaRuntime& jr) {
if (!jr.env->ExceptionCheck())
return "No Exception";
- jr.env->ExceptionDescribe();
+ const jthrowable ex = jr.env->ExceptionOccurred();
+ const jstring trace = (jstring)jr.env->CallStaticObjectMethod(jr.invokerClass, jr.invokerStackTrace, ex);
+ const char* c = jr.env->GetStringUTFChars(trace, NULL);
+ const string msg(c);
+ jr.env->ReleaseStringUTFChars(trace, c);
jr.env->ExceptionClear();
- return "UnknownException";
+ return msg;
}
/**