parent
385b135bf2
commit
a39da55d97
|
@ -9,6 +9,10 @@
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
public class Monitor2 {
|
public class Monitor2 {
|
||||||
|
private static boolean randomIsolate() {
|
||||||
|
return Math.random() > .5;
|
||||||
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
public Monitor2() { }
|
public Monitor2() { }
|
||||||
|
|
|
@ -75,7 +75,8 @@ private:
|
||||||
jclass _jre;
|
jclass _jre;
|
||||||
jmethodID _ctr;
|
jmethodID _ctr;
|
||||||
jmethodID _wrapper_ctr;
|
jmethodID _wrapper_ctr;
|
||||||
|
jmethodID _message;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Exceptions(JNIEnv *java_env, jmp_buf& c_env);
|
Exceptions(JNIEnv *java_env, jmp_buf& c_env);
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
|
|
||||||
extern JNIEnv *launch(char *);
|
extern "C" JNIEnv *launch(char *);
|
||||||
extern void kill();
|
extern "C" void kill();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -13,6 +13,7 @@ Exceptions::Exceptions(JNIEnv *java_env, jmp_buf& c_env) :
|
||||||
{
|
{
|
||||||
_jre = java_env->FindClass("java/lang/RuntimeException");
|
_jre = java_env->FindClass("java/lang/RuntimeException");
|
||||||
_ctr = java_env->GetMethodID(_jre, "<init>", "(Ljava/lang/String;)V");
|
_ctr = java_env->GetMethodID(_jre, "<init>", "(Ljava/lang/String;)V");
|
||||||
|
_message = java_env->GetMethodID(_jre, "getMessage", "()Ljava/lang/String;");
|
||||||
_wrapper_ctr =
|
_wrapper_ctr =
|
||||||
java_env->GetMethodID(_jre,
|
java_env->GetMethodID(_jre,
|
||||||
"<init>",
|
"<init>",
|
||||||
|
@ -27,9 +28,13 @@ void Exceptions::throwException(const char *file_name, int line_number) {
|
||||||
jthrowable real_ex = _java_env->ExceptionOccurred();
|
jthrowable real_ex = _java_env->ExceptionOccurred();
|
||||||
_java_env->ExceptionClear();
|
_java_env->ExceptionClear();
|
||||||
|
|
||||||
char msg[strlen(file_name) + 1024];
|
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];
|
||||||
memset(msg, 0, strlen(file_name) + 1024);
|
memset(msg, 0, strlen(file_name) + 1024);
|
||||||
sprintf(msg, "exception at %s:%d", file_name, line_number);
|
sprintf(msg, "exception at %s:%d: %s", file_name, line_number, m);
|
||||||
jstring java_message = _java_env->NewStringUTF(msg);
|
jstring java_message = _java_env->NewStringUTF(msg);
|
||||||
|
|
||||||
jthrowable ex = (jthrowable)
|
jthrowable ex = (jthrowable)
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include "Exceptions.h"
|
#include "Exceptions.h"
|
||||||
#include "CAstWrapper.h"
|
#include "CAstWrapper.h"
|
||||||
|
#include "launch.h"
|
||||||
|
|
||||||
JavaVM *javaVM;
|
JavaVM *javaVM;
|
||||||
|
|
||||||
JNIEnv *launch(char *classpath) {
|
JNIEnv *launch(char *classpath) {
|
||||||
JavaVMOption jvmopt[2];
|
JavaVMOption jvmopt[2];
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,8 @@ Require-Bundle: com.ibm.wala.cast.java.test;bundle-version="1.0.0",
|
||||||
org.eclipse.ui.ide,
|
org.eclipse.ui.ide,
|
||||||
org.eclipse.ui.ide.application,
|
org.eclipse.ui.ide.application,
|
||||||
org.eclipse.ant.launching,
|
org.eclipse.ant.launching,
|
||||||
com.ibm.wala.cast.java.ecj
|
com.ibm.wala.cast.java.ecj,
|
||||||
|
com.ibm.wala.shrike
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||||
Export-Package: com.ibm.wala.cast.java.jdt.test,
|
Export-Package: com.ibm.wala.cast.java.jdt.test,
|
||||||
|
|
Loading…
Reference in New Issue