This commit is contained in:
Julian Dolby 2017-09-16 18:25:35 +00:00
commit 3ee1f2d368
4 changed files with 6 additions and 12 deletions

View File

@ -75,8 +75,7 @@ private:
jclass _jre;
jmethodID _ctr;
jmethodID _wrapper_ctr;
jmethodID _message;
public:
Exceptions(JNIEnv *java_env, jmp_buf& c_env);

View File

@ -3,7 +3,7 @@
#include "jni.h"
extern "C" JNIEnv *launch(char *);
extern "C" void kill();
extern JNIEnv *launch(char *);
extern void kill();
#endif

View File

@ -13,7 +13,6 @@ Exceptions::Exceptions(JNIEnv *java_env, jmp_buf& c_env) :
{
_jre = java_env->FindClass("java/lang/RuntimeException");
_ctr = java_env->GetMethodID(_jre, "<init>", "(Ljava/lang/String;)V");
_message = java_env->GetMethodID(_jre, "getMessage", "()Ljava/lang/String;");
_wrapper_ctr =
java_env->GetMethodID(_jre,
"<init>",
@ -28,13 +27,9 @@ void Exceptions::throwException(const char *file_name, int line_number) {
jthrowable real_ex = _java_env->ExceptionOccurred();
_java_env->ExceptionClear();
jstring message = (jstring)
_java_env->CallObjectMethod(real_ex, _message);
const char *m = _java_env->GetStringUTFChars(message, false);
char msg[strlen(file_name) + strlen(m) + 1024];
char msg[strlen(file_name) + 1024];
memset(msg, 0, strlen(file_name) + 1024);
sprintf(msg, "exception at %s:%d: %s", file_name, line_number, m);
sprintf(msg, "exception at %s:%d", file_name, line_number);
jstring java_message = _java_env->NewStringUTF(msg);
jthrowable ex = (jthrowable)

View File

@ -3,9 +3,9 @@
#include <strings.h>
#include "Exceptions.h"
#include "CAstWrapper.h"
#include "launch.h"
JavaVM *javaVM;
JNIEnv *launch(char *classpath) {
JavaVMOption jvmopt[2];