ext/load.c in rjb-1.1.7 vs ext/load.c in rjb-1.1.8
- old
+ new
@@ -10,11 +10,11 @@
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * $Id: load.c 85 2009-02-04 16:14:22Z kuwa1 $
+ * $Id: load.c 91 2009-09-07 14:13:17Z arton $
*/
#include <stdlib.h>
#include <stdio.h>
#include "ruby.h"
@@ -43,11 +43,11 @@
#define JVMDLL "%s\\jre\\bin\\%s\\jvm.dll"
#define DIRSEPARATOR '\\'
#endif
#define CLASSPATH_SEP ';'
#elif defined(__APPLE__) && defined(__MACH__)
- #define JVMDLL "%s/Libraries/libjvm_compat.dylib"
+ static char* JVMDLL = "%s/Libraries/libjvm_compat.dylib";
#define DIRSEPARATOR '/'
#define CLASSPATH_SEP ':'
#define HOME_NAME "/Home"
#define HOME_NAME_LEN strlen(HOME_NAME)
#define DEFAULT_HOME "/System/Library/Frameworks/JavaVM.framework"
@@ -80,10 +80,18 @@
#define JVMDLL "%s/jre/lib/%s/%s/libjvm.so"
#define DIRSEPARATOR '/'
#define CLASSPATH_SEP ':'
#endif
+#if defined(__APPLE__) && defined(__MACH__)
+ static char* CREATEJVM = "JNI_CreateJavaVM";
+ static char* GETDEFAULTJVMINITARGS = "JNI_GetDefaultJavaVMInitArgs";
+#else
+ #define CREATEJVM "JNI_CreateJavaVM"
+ #define GETDEFAULTJVMINITARGS "JNI_GetDefaultJavaVMInitArgs"
+#endif
+
typedef int (*GETDEFAULTJAVAVMINITARGS)(void*);
typedef int (*CREATEJAVAVM)(JavaVM**, JNIEnv**, void*);
static VALUE jvmdll = Qnil;
@@ -170,15 +178,15 @@
{
return 0;
}
/* get function pointers of JNI */
#if RJB_RUBY_VERSION_CODE < 190
- 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);
- createjavavmfunc = rb_funcall(rb_funcall(rb_funcall(jvmdll, rb_intern("[]"), 2, rb_str_new2("JNI_CreateJavaVM"), rb_str_new2("IPPP")), rb_intern("to_ptr"), 0), rb_intern("to_i"), 0);
+ getdefaultjavavminitargsfunc = rb_funcall(rb_funcall(rb_funcall(jvmdll, rb_intern("[]"), 2, rb_str_new2(GETDEFAULTJVMINITARGS), rb_str_new2("IP")), rb_intern("to_ptr"), 0), rb_intern("to_i"), 0);
+ createjavavmfunc = rb_funcall(rb_funcall(rb_funcall(jvmdll, rb_intern("[]"), 2, rb_str_new2(CREATEJVM), rb_str_new2("IPPP")), rb_intern("to_ptr"), 0), rb_intern("to_i"), 0);
#else
- getdefaultjavavminitargsfunc = rb_funcall(jvmdll, rb_intern("[]"), 1, rb_str_new2("JNI_GetDefaultJavaVMInitArgs"));
- createjavavmfunc = rb_funcall(jvmdll, rb_intern("[]"), 1, rb_str_new2("JNI_CreateJavaVM"));
+ getdefaultjavavminitargsfunc = rb_funcall(jvmdll, rb_intern("[]"), 1, rb_str_new2(GETDEFAULTJVMINITARGS));
+ createjavavmfunc = rb_funcall(jvmdll, rb_intern("[]"), 1, rb_str_new2(CREATEJVM));
#endif
return 1;
}
static int load_bridge(JNIEnv* jenv)
@@ -254,10 +262,18 @@
int i;
VALUE optval;
if (!RTEST(jvmdll))
{
- if (!(load_jvm(JVM_TYPE) || load_jvm(ALT_JVM_TYPE)))
+#if defined(__APPLE__) && defined(__MACH__)
+ if (!(load_jvm(JVM_TYPE) || load_jvm(ALT_JVM_TYPE)))
+ {
+ JVMDLL = "%s/Libraries/libjvm.dylib";
+ CREATEJVM = "JNI_CreateJavaVM_Impl";
+ GETDEFAULTJVMINITARGS = "JNI_GetDefaultJavaVMInitArgs_Impl";
+ }
+#endif
+ if (!(load_jvm(JVM_TYPE) || load_jvm(ALT_JVM_TYPE)))
{
return -1;
}
}