| CODENOTIFIER | HelpYou are not signed inSign in |
Project: RJB
Revision: 81
Author: arton
Date: 26 Aug 2008 08:44:44
Changes:catch DL's exception
Files:| ... | ...@@ -15,7 +15,7 @@ | |
| 15 | 15 | * $Id$ |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | #define RJB_VERSION "1.1.5" | |
| 18 | #define RJB_VERSION "1.1.6" | |
| 19 | 19 | |
| 20 | 20 | #include "ruby.h" |
| 21 | 21 | #include "extconf.h" |
| ... | ...@@ -2779,7 +2779,7 @@ | |
| 2779 | 2779 | rb_gc_register_address(&rjbb); |
| 2780 | 2780 | } |
| 2781 | 2781 | |
| 2782 | static VALUE safe_funcall(VALUE args) | |
| 2782 | VALUE rjb_safe_funcall(VALUE args) | |
| 2783 | 2783 | { |
| 2784 | 2784 | VALUE* argp = (VALUE*)args; |
| 2785 | 2785 | return rb_funcall2(*argp, *(argp + 1), *(argp + 2), argp + 3); |
| ... | ...@@ -2829,7 +2829,7 @@ | |
| 2829 | 2829 | *argv = ptr->wrapped; |
| 2830 | 2830 | *(argv + 1) = id; |
| 2831 | 2831 | *(argv + 2) = argc - 3; |
| 2832 | result = rb_protect(safe_funcall, (VALUE)argv, &sstat); | |
| 2832 | result = rb_protect(rjb_safe_funcall, (VALUE)argv, &sstat); | |
| 2833 | 2833 | rv2jobject(jenv, result, &j, NULL, 0); |
| 2834 | 2834 | /* I can't delete this object... */ |
| 2835 | 2835 | break; |
| ... | ...@@ -90,6 +90,8 @@ | |
| 90 | 90 | char* libpath; |
| 91 | 91 | char* java_home; |
| 92 | 92 | char* jh; |
| 93 | int sstat; | |
| 94 | VALUE* argv; | |
| 93 | 95 | |
| 94 | 96 | jh = getenv("JAVA_HOME"); |
| 95 | 97 | #if defined(__APPLE__) && defined(__MACH__) |
| ... | ...@@ -150,9 +152,16 @@ | |
| 150 | 152 | rb_raise(rb_eRuntimeError, "Constants DL is not defined."); |
| 151 | 153 | return 0; |
| 152 | 154 | } |
| 153 | ||
| 154 | jvmdll = rb_funcall(rb_const_get(rb_cObject, rb_intern("DL")), rb_intern("dlopen"), 1, rb_str_new2(libpath)); | |
| 155 | ||
| 155 | argv = ALLOCA_N(VALUE, 4); | |
| 156 | *argv = rb_const_get(rb_cObject, rb_intern("DL")); | |
| 157 | *(argv + 1) = rb_intern("dlopen"); | |
| 158 | *(argv + 2) = 1; | |
| 159 | *(argv + 3) = rb_str_new2(libpath); | |
| 160 | jvmdll = rb_protect(rjb_safe_funcall, (VALUE)argv, &sstat); | |
| 161 | if (sstat) | |
| 162 | { | |
| 163 | return 0; | |
| 164 | } | |
| 156 | 165 | /* get function pointers of JNI */ |
| 157 | 166 | #if RJB_RUBY_VERSION_CODE < 190 |
| 158 | 167 | getdefaultjavavminitargsfunc = rb_funcall(rb_funcall(rb_funcall(jvmdll, rb_intern("[]"), 2, rb_str_new2("JNI_GetDefaultJavaVMInitArgs"), rb_str_new2("IP")), rb_intern("to_ptr"), 0), rb_intern("to_i"), 0); |
| ... | ...@@ -69,6 +69,7 @@ | |
| 69 | 69 | extern jclass rjb_find_class(JNIEnv* jenv, VALUE name); |
| 70 | 70 | extern void rjb_release_string(JNIEnv *jenv, jstring str, const char* chrs); |
| 71 | 71 | extern VALUE rjb_load_vm_default(); |
| 72 | extern VALUE rjb_safe_funcall(VALUE args); | |
| 72 | 73 | |
| 73 | 74 | /* in rjbexception.c */ |
| 74 | 75 | extern VALUE rjb_get_exception_class(JNIEnv* jenv, jstring str); |
| ... | ...@@ -1,3 +1,7 @@ | |
| 1 | Tue Aug 26 arton | |
| 2 | *ext/load.c, rjb.c, rjb.h | |
| 3 | export safe_funcall under the prefix 'rjb'. | |
| 4 | calling DL with rb_protect for avoiding exception. | |
| 1 | 5 | Mon Aug 25 arton |
| 2 | 6 | *ext/load.c |
| 3 | 7 | Fix checking the result for loading alternate_jvm_type. |