rjb 1.1.0-x86-mswin32-60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,270 @@
1
+ Tue Dec 27 Kuwashima
2
+ *test/Test.java
3
+ *test/test.rb
4
+ *ext/depend
5
+ *ext/load.c
6
+ *ext/extconf.rb
7
+ *ext/rjbexception.c
8
+ *ext/rjb.c
9
+ *ext/riconv.c
10
+ change for compatibility with Ruby-1.9.0
11
+ Tue Nov 20 arton
12
+ *rjb.c
13
+ mark version 1.10.12 for next relase.
14
+ *load.c
15
+ omit useless double-quotations from JAVA_HOME, maybe specifies a longpathname (but useless).
16
+ Wed Nov 14 Kuwashima
17
+ *rjb.c
18
+ add error check to constructor.
19
+ Fri Nov 9 arton
20
+ *test.rb
21
+ *Test.java
22
+ add test for reproducing rjb-bugs-15430
23
+ *rjb.c
24
+ fix rjb-bugs-15430 that caused by bad array conversion.
25
+ (generics method result signature is an object, but the real result is typed array)
26
+ *riconv.c
27
+ correct to get the number of array element.
28
+ Tue Oct 23 Kuwashima
29
+ *riconv.c
30
+ Change string encoding conversion rule.
31
+ Mon Oct 22 Kuwashima
32
+ *riconv.c
33
+ *riconv.h
34
+ recycle iconv instance.
35
+ *test/test.rb
36
+ add cases for test_kjconv
37
+ Sun Sep 23 arton
38
+ *rjb.c
39
+ version 1.0.9
40
+ convert to Ruby's type if Rjb::primitive_converion is enalbed and the result type is java.lang.Object
41
+ support the object conversion for a bignum to long.
42
+ Sat Sep 15 arton
43
+ *rjb.c
44
+ version 1.0.8
45
+ correction of 1.0.7, support long type.
46
+ Fri Sep 14 arton
47
+ *rjb.c
48
+ version 1.0.7
49
+ add auto primitive conversion toggled by Rjb::primitive_conversion
50
+ *test.rb
51
+ add test_auto_conv
52
+ Sun Jun 17 arton
53
+ *rjb.c
54
+ add method aliases.
55
+ setXxYy -> xx_yy=
56
+ getXxYy -> xx_yy
57
+ isXxYy -> xx_yy?
58
+ xxYyZz -> xx_yy_zz
59
+ *test.rb
60
+ add a test for the method alias feature.
61
+ Tue Nov 21 arton
62
+ *rjb.c
63
+ Skip the constant registering process, if the constant was already defined.
64
+ *load.c
65
+ *rjb.c
66
+ *rjbexception.c
67
+ *rjb.h
68
+ add prefix 'rjb' for externed symbol names to avoid confliction.
69
+
70
+ Sun Oct 08 arton (on behalf of richard apodaca)
71
+ *load.c
72
+ support AMD64
73
+
74
+ Mon Sep 11 arton
75
+ *test.rb
76
+ add a test of arguments types are various array.
77
+ *Test.java
78
+ add a test of arguments types are various array.
79
+ *rjb.c
80
+ accept nil for array parameter.
81
+ Sun Sep 10 arton
82
+ *test.rb
83
+ add a test of return type is an object wrapped an array
84
+ *Test.java
85
+ add a method that returns an object wrapped an array
86
+ *rjb.c
87
+ check array-mark in jv2rv for returned object was an array
88
+ Tue Aug 1 arton
89
+ *load.c
90
+ *rjb.c
91
+ change load pathname of the bridge class.
92
+ *post-install.rb
93
+ add for remove previous installed rjb.so.
94
+ *rjb.rake
95
+ add for build Gem.
96
+ *rjb.rb
97
+ for preparing the pathname constant of the bridge class.
98
+ *depend
99
+ chage binary name from rjb.so to rjbcore.so
100
+ *extconf.rb
101
+ chage binary name from rjb.so to rjbcore.so
102
+
103
+ Mon Jul 31 arton
104
+ *load.c
105
+ fix buffer allocation
106
+
107
+ Sun Jul 16 (Jun 22) Kuwashima and arton
108
+ *rjb.c
109
+ version 0.2.8
110
+ *MANIFEST
111
+ *depend
112
+ *load.c
113
+ *rjbexception.c
114
+ change jni.h to jniwrap.h.
115
+ change the bridge class's header according to JDK 5.0's javah.
116
+ *jniwrap.h
117
+ wrap jni.h for Cygin
118
+
119
+ Sat Jun 10 14:10:05 2006 arton
120
+ *rjb.c
121
+ version 0.2.7
122
+ support an array of arrays from ruby to java.
123
+
124
+ Mon May 8 08:52:12 2006 arton
125
+ *load.c
126
+ revision 5
127
+ support both Intel and PPC Mac.
128
+ Patched version was contributed by Demetrius Nunes.
129
+
130
+ Wed Apr 12 03:57:12 2006 arton
131
+ *rjb.c
132
+ version 0.2.6
133
+ support an array of arrays.
134
+ *test.rb
135
+ add an array of arrays test, some tests are contributed by Darren Day.
136
+ *Test.java
137
+ add a test method that returns an array of arrays, some tests are
138
+ contributed by Darren Day.
139
+
140
+ Sat Dec 24 18:56:38 2005 arton
141
+ *rjb.c
142
+ version 0.2.5
143
+ release String, Float, Array object after method call.
144
+ *gctest.rb
145
+ add for String object gc test
146
+
147
+ Mon Sep 19 01:09:30 2005 arton
148
+ *rjb.c
149
+ version 0.2.4
150
+ use null instead of empty string when String argument is nil
151
+ omit unused local variable from jstring2val
152
+ *test.rb
153
+ add null string test (bug since utf-8 support)
154
+
155
+ Tue Jun 28 01:57:07 2005 arton
156
+ *rjb.c
157
+ version 0.2.3
158
+ convert result object to imported class if object is an instance of Class
159
+ call Class#forName if argument count is 1
160
+ *test.rb
161
+ add test_importobj contributed by Mr. Kuwashima, thanks.
162
+
163
+ Mon Jun 27 20:30:50 2005 arton
164
+ treat Class.forName as Rjb::import
165
+ *rjb.c
166
+ version 0.2.2
167
+ add method 'forName' into imported Class object
168
+ if pass imported object to JVM, extract Class object from ruby object
169
+ *test.rb
170
+ add above tests
171
+
172
+ Sat Jun 25 05:58:36 2005 arton
173
+ most bugs were reported by Mr. Micael Weller, thanks.
174
+ *rjb.c
175
+ version 0.2.1
176
+ correct derived static method search
177
+ search class methods then class's instance methods when called by class
178
+ avoid register non capitalized named constants into constants table
179
+ correct capitalized named method search
180
+ *riconv.c
181
+ never call iconv if $KCODE is nil
182
+ *load.c
183
+ using path separator ; for cygwin (by Ryugate)
184
+
185
+ Sun Apr 24 05:26:16 2005 arton
186
+ *rb.c
187
+ version 0.2.0
188
+ delete localref if globalref was created.
189
+ load can take the second argument for jvm
190
+ *load.c
191
+ load can take the second argument for jvm
192
+
193
+ Mon Jan 17 02:40:21 2005 arton
194
+ *rjb.c
195
+ add 'throw' module function.
196
+ move java exception handling functions into newly created rjbexception.c
197
+ *rjb.h
198
+ declations for rjb.c and rjbexception.c
199
+ *rjbexception.c
200
+ java exception handling functions, and 'throw' module function.
201
+ *test.rb
202
+ adding throw test.
203
+
204
+ Wed Jan 12 00:01:08 2005 Kaspar Schiess and arton
205
+ *rjb.c
206
+ correct Rjb::load parameter evaluation (classpath).
207
+ - many thanks to Mr.Schiess.
208
+
209
+ Sun Nov 21 02:51:43 2004 Kuwashima and arton
210
+ *rjb.c
211
+ move dbcs-utf-8 auto conversion feature into riconv.?
212
+ remove JNI version argument from Rjb::load. (bug reported by Mr.Tateishi)
213
+ *load.c
214
+ correct CLASSPATH setting (bad environment name).(bug reported by Mr.Tateishi)
215
+ *riconv.c riconv.h (contributed by Mr.Kuwashima)
216
+ DBCS - utf-8 auto conversion functions.
217
+ *depend MANIFEST
218
+ add riconv.?
219
+ - many tanks to Mr.Kuwashima and Mr.Tateishi.
220
+
221
+ Tue Oct 5 23:08:59 2004 Kuwashima and arton
222
+ *test.rb
223
+ add kanji conversion test
224
+ *rjb.c
225
+ add dbcs(sjis and euc-jp) - utf-8 auto conversion feature.
226
+ the patch was contributed by Mr.Kuwashima, many thanks.
227
+
228
+ Sun Oct 3 18:24:42 2004 arton
229
+ *load.c
230
+ JNIEnv* now using local variable instead of global one.
231
+ Because AWT event use a worker thread, and JNI need thread's owned JNIEnv.
232
+ *rjb.c
233
+ JNIEnv* now using local variable instead of global one.
234
+ Because AWT event use a worker thread, and JNI need thread's owned JNIEnv.
235
+ This change was suggested by Mr.Kuwashima, he also tested the behavior,
236
+ and gave me some test codes.
237
+ and attach_current_thread is from Mr.Kuwashima's patch.
238
+ Many thanks to Mr.Kuwashima.
239
+
240
+ Sat Sep 25 03:25:45 2004 arton
241
+ *rjb.c
242
+ implements interface's method argument conversion.
243
+ *test.rb
244
+ add Comparable test (interface with method arguments)
245
+ *Test.java
246
+ add Comparable test method.
247
+
248
+ Wed Sep 22 02:30:15 2004 arton
249
+ *rjb.c
250
+ correct constants load, using mid-class.
251
+ convert null string to nil
252
+
253
+ Wed Sep 22 00:05:32 2004 arton
254
+ *rjb.c
255
+ correct ruby type checking. If the parameter type is java.lang.String, rjb instance is always accepted.
256
+
257
+ Mon Sep 20 22:02:53 2004 arton
258
+ *rjb.c
259
+ checking method/constructor signature with class when the argument is rjb's instance.
260
+ Sun Sep 19 00:54:35 2004 arton
261
+ *rjb.c
262
+ convert Java exception to Ruby's StandardError derived class.
263
+ checking method/constructor signature when invoking if no signatur argument is supplied.
264
+ adding field accessor.
265
+
266
+ Sun Sep 12 21:42:00 2004 arton
267
+ *rjb.c
268
+ call exception description when verbose = true.
269
+ correct recursive import call (for Boolean).
270
+ corrent method not found message creation.
@@ -0,0 +1,39 @@
1
+ /*
2
+ * Rjb - Ruby <-> Java Bridge
3
+ * Copyright(c) 2004 arton
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * $Id: RBridge.java 2 2006-04-11 19:04:40Z arton $
16
+ * $Log: RBridge.java,v $
17
+ * Revision 1.2 2004/06/19 09:05:00 arton
18
+ * delete debug lines
19
+ *
20
+ * Revision 1.1 2004/06/19 09:00:19 arton
21
+ * Initial revision
22
+ *
23
+ */
24
+ package jp.co.infoseek.hp.arton.rjb;
25
+ import java.lang.reflect.InvocationHandler;
26
+ import java.lang.reflect.Method;
27
+ import java.lang.reflect.Proxy;
28
+
29
+ public class RBridge implements InvocationHandler {
30
+ public Object register(Class itf) {
31
+ return Proxy.newProxyInstance(itf.getClassLoader(),
32
+ new Class[] { itf }, this);
33
+ }
34
+ public Object invoke(Object proxy, Method method, Object[] args)
35
+ throws Throwable {
36
+ return call(method.getName(), proxy, args);
37
+ }
38
+ private native Object call(String methodName, Object target, Object[] args);
39
+ }
@@ -0,0 +1,23 @@
1
+ riconv.o : riconv.c jp_co_infoseek_hp_arton_rjb_RBridge.h
2
+ rjb.o : rjb.c jp_co_infoseek_hp_arton_rjb_RBridge.h riconv.h rjb.h
3
+ rjbexception.o : rjbexception.c jp_co_infoseek_hp_arton_rjb_RBridge.h riconv.h rjb.h
4
+ load.o : load.c jp_co_infoseek_hp_arton_rjb_RBridge.h
5
+ jp_co_infoseek_hp_arton_rjb_RBridge.h : jniwrap.h ../data/rjb/jp/co/infoseek/hp/arton/rjb/RBridge.class
6
+ javah -classpath ../data/rjb jp.co.infoseek.hp.arton.rjb.RBridge
7
+ ../data/rjb/jp/co/infoseek/hp/arton/rjb/RBridge.class : RBridge.java
8
+ mkdir -p ../data/rjb/jp/co/infoseek/hp/arton/rjb
9
+ javac -d ../data/rjb RBridge.java
10
+ test : rjbcore.so ../test/jp/co/infoseek/hp/arton/rjb/Test.class ../test/jp/co/infoseek/hp/arton/rjb/IBase.class ../test/jp/co/infoseek/hp/arton/rjb/Base.class ../test/jp/co/infoseek/hp/arton/rjb/ExtBase.class
11
+ ruby ../test/test.rb
12
+ ../test/jp/co/infoseek/hp/arton/rjb/Test.class : ../test/Test.java
13
+ javac ../test/Test.java
14
+ $(RUBY) -r fileutils -e 'FileUtils.mkdir_p "../test/jp/co/infoseek/hp/arton/rjb";FileUtils.mv("../test/Test.class", "../test/jp/co/infoseek/hp/arton/rjb")'
15
+ ../test/jp/co/infoseek/hp/arton/rjb/IBase.class : ../test/IBase.java
16
+ javac ../test/IBase.java
17
+ $(RUBY) -r fileutils -e 'FileUtils.mkdir_p "../test/jp/co/infoseek/hp/arton/rjb";FileUtils.mv("../test/IBase.class", "../test/jp/co/infoseek/hp/arton/rjb")'
18
+ ../test/jp/co/infoseek/hp/arton/rjb/Base.class : ../test/Base.java ../test/jp/co/infoseek/hp/arton/rjb/IBase.class
19
+ javac -classpath ../test ../test/Base.java
20
+ $(RUBY) -r fileutils -e 'FileUtils.mkdir_p "../test/jp/co/infoseek/hp/arton/rjb";FileUtils.mv("../test/Base.class", "../test/jp/co/infoseek/hp/arton/rjb")'
21
+ ../test/jp/co/infoseek/hp/arton/rjb/ExtBase.class : ../test/ExtBase.java
22
+ javac -classpath ../test ../test/ExtBase.java
23
+ $(RUBY) -r fileutils -e 'FileUtils.mkdir_p "../test/jp/co/infoseek/hp/arton/rjb";FileUtils.mv("../test/ExtBase.class", "../test/jp/co/infoseek/hp/arton/rjb")'
@@ -0,0 +1,8 @@
1
+ #ifndef EXTCONF_H
2
+ #define EXTCONF_H
3
+ #define HAVE_JNI_H 1
4
+ #define HAVE_DL_H 1
5
+ #define HAVE_SETLOCALE 1
6
+ #define HAVE_GETENV 1
7
+ #define RJB_RUBY_VERSION_CODE 186
8
+ #endif
@@ -0,0 +1,32 @@
1
+ /*
2
+ * Rjb - Ruby <-> Java Bridge
3
+ * Copyright(c) 2006 Kuwashima
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * $Id: jniwrap.h 4 2006-09-11 15:21:38Z arton $
16
+ */
17
+ #ifndef _Included_jniwrap
18
+ #define _Included_jniwrap
19
+ #ifdef __cplusplus
20
+ extern "C" {
21
+ #endif
22
+
23
+ #if defined(__GNUC__) && (defined(__CYGWIN32__) || defined(__MINGW32__))
24
+ typedef long long __int64;
25
+ #endif
26
+
27
+ #include <jni.h>
28
+
29
+ #ifdef __cplusplus
30
+ }
31
+ #endif
32
+ #endif
@@ -0,0 +1,21 @@
1
+ /* DO NOT EDIT THIS FILE - it is machine generated */
2
+ #include <jni.h>
3
+ /* Header for class jp_co_infoseek_hp_arton_rjb_RBridge */
4
+
5
+ #ifndef _Included_jp_co_infoseek_hp_arton_rjb_RBridge
6
+ #define _Included_jp_co_infoseek_hp_arton_rjb_RBridge
7
+ #ifdef __cplusplus
8
+ extern "C" {
9
+ #endif
10
+ /*
11
+ * Class: jp_co_infoseek_hp_arton_rjb_RBridge
12
+ * Method: call
13
+ * Signature: (Ljava/lang/String;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
14
+ */
15
+ JNIEXPORT jobject JNICALL Java_jp_co_infoseek_hp_arton_rjb_RBridge_call
16
+ (JNIEnv *, jobject, jstring, jobject, jobjectArray);
17
+
18
+ #ifdef __cplusplus
19
+ }
20
+ #endif
21
+ #endif
@@ -0,0 +1,287 @@
1
+ /*
2
+ * Rjb - Ruby <-> Java Bridge
3
+ * Copyright(c) 2004,2005,2006 arton
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * $Id: load.c 43 2007-12-26 18:55:04Z kuwa1 $
16
+ */
17
+
18
+ #include <stdlib.h>
19
+ #include <stdio.h>
20
+ #include "ruby.h"
21
+ #include "extconf.h"
22
+ #if RJB_RUBY_VERSION_CODE < 190
23
+ #include "intern.h"
24
+ #include "st.h"
25
+ #include "util.h"
26
+ #else
27
+ #include "ruby/intern.h"
28
+ #include "ruby/st.h"
29
+ #include "ruby/util.h"
30
+ #endif
31
+ #include "jniwrap.h"
32
+ #include "jp_co_infoseek_hp_arton_rjb_RBridge.h"
33
+ #include "rjb.h"
34
+
35
+ #define JVM_TYPE "client"
36
+
37
+ #if defined(_WIN32) || defined(__CYGWIN__)
38
+ #if defined(__CYGWIN__)
39
+ #define JVMDLL "%s/jre/bin/%s/jvm.dll"
40
+ #define DIRSEPARATOR '/'
41
+ #else
42
+ #define JVMDLL "%s\\jre\\bin\\%s\\jvm.dll"
43
+ #define DIRSEPARATOR '\\'
44
+ #endif
45
+ #define CLASSPATH_SEP ';'
46
+ #elif defined(__APPLE__) && defined(__MACH__)
47
+ #define JVMDLL "%s/Libraries/libjvm_compat.dylib"
48
+ #define DIRSEPARATOR '/'
49
+ #define CLASSPATH_SEP ':'
50
+ #else /* defined(_WIN32) || defined(__CYGWIN__) */
51
+ #if defined(__sparc_v9__)
52
+ #define ARCH "sparcv9"
53
+ #elif defined(__sparc__)
54
+ #define ARCH "sparc"
55
+ #elif defined(__amd64__)
56
+ #define ARCH "amd64"
57
+ #undef JVM_TYPE
58
+ #define JVM_TYPE "server"
59
+ #elif defined(i586) || defined(__i386__)
60
+ #define ARCH "i386"
61
+ #endif
62
+ #ifndef ARCH
63
+ #include <sys/systeminfo.h>
64
+ #endif
65
+ #define JVMDLL "%s/jre/lib/%s/%s/libjvm.so"
66
+ #define DIRSEPARATOR '/'
67
+ #define CLASSPATH_SEP ':'
68
+ #endif
69
+
70
+ typedef int (*GETDEFAULTJAVAVMINITARGS)(void*);
71
+ typedef int (*CREATEJAVAVM)(JavaVM**, JNIEnv**, void*);
72
+
73
+
74
+ static VALUE jvmdll = Qnil;
75
+ static VALUE getdefaultjavavminitargsfunc;
76
+ static VALUE createjavavmfunc;
77
+
78
+ /*
79
+ * not completed, only valid under some circumstances.
80
+ */
81
+ static int load_jvm(char* jvmtype)
82
+ {
83
+ char* libpath;
84
+ char* java_home;
85
+ char* jh;
86
+ VALUE dl;
87
+ VALUE importer;
88
+
89
+ #if defined(__APPLE__) && defined(__MACH__)
90
+ jh = "/System/Library/Frameworks/JavaVM.framework";
91
+ #else
92
+ jh = getenv("JAVA_HOME");
93
+ #endif
94
+ if (!jh)
95
+ {
96
+ return 0;
97
+ }
98
+ #if defined(_WIN32)
99
+ if (*jh == '"' && *(jh + strlen(jh) - 1) == '"')
100
+ {
101
+ char* p = ALLOCA_N(char, strlen(jh) + 1);
102
+ strcpy(p, jh + 1);
103
+ *(p + strlen(p) - 1) = '\0';
104
+ jh = p;
105
+ }
106
+ #endif
107
+ java_home = ALLOCA_N(char, strlen(jh) + 1);
108
+ strcpy(java_home, jh);
109
+ if (*(java_home + strlen(jh) - 1) == DIRSEPARATOR)
110
+ {
111
+ *(java_home + strlen(jh) - 1) = '\0';
112
+ }
113
+ #if defined(_WIN32) || defined(__CYGWIN__)
114
+ libpath = ALLOCA_N(char, sizeof(JVMDLL) + strlen(java_home)
115
+ + strlen(jvmtype) + 1);
116
+ sprintf(libpath, JVMDLL, java_home, jvmtype);
117
+ #elif defined(__APPLE__) && defined(__MACH__)
118
+ libpath = ALLOCA_N(char, sizeof(JVMDLL) + strlen(java_home) + 1);
119
+ sprintf(libpath, JVMDLL, java_home);
120
+ #else /* not Windows / MAC OS-X */
121
+ libpath = ALLOCA_N(char, sizeof(JVMDLL) + strlen(java_home)
122
+ + strlen(ARCH) + strlen(jvmtype) + 1);
123
+ sprintf(libpath, JVMDLL, java_home, ARCH, jvmtype);
124
+ #endif
125
+
126
+ rb_require("dl");
127
+ if (!rb_const_defined_at(rb_cObject, rb_intern("DL")))
128
+ {
129
+ rb_raise(rb_eRuntimeError, "Constants DL is not defined.");
130
+ return 0;
131
+ }
132
+
133
+ jvmdll = rb_funcall(rb_const_get(rb_cObject, rb_intern("DL")), rb_intern("dlopen"), 1, rb_str_new2(libpath));
134
+
135
+ #if RJB_RUBY_VERSION_CODE < 190
136
+ 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);
137
+ 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);
138
+ #else
139
+ getdefaultjavavminitargsfunc = rb_funcall(jvmdll, rb_intern("[]"), 1, rb_str_new2("JNI_GetDefaultJavaVMInitArgs"));
140
+ createjavavmfunc = rb_funcall(jvmdll, rb_intern("[]"), 1, rb_str_new2("JNI_CreateJavaVM"));
141
+ #endif
142
+ return 1;
143
+ }
144
+
145
+ static int load_bridge(JNIEnv* jenv)
146
+ {
147
+ JNINativeMethod nmethod[1];
148
+ jbyte buff[8192];
149
+ char* bridge;
150
+ int len;
151
+ FILE* f;
152
+ jclass loader = (*jenv)->FindClass(jenv, "java/lang/ClassLoader");
153
+ jmethodID getSysLoader = (*jenv)->GetStaticMethodID(jenv, loader,
154
+ "getSystemClassLoader", "()Ljava/lang/ClassLoader;");
155
+ jobject iloader = (*jenv)->CallStaticObjectMethod(jenv, loader, getSysLoader);
156
+ VALUE v = rb_const_get_at(rb_const_get(rb_cObject, rb_intern("RjbConf")),
157
+ rb_intern("BRIDGE_FILE"));
158
+ bridge = StringValuePtr(v);
159
+ #if defined(DOSISH)
160
+ bridge = ALLOCA_N(char, strlen(bridge) + 8);
161
+ strcpy(bridge, StringValuePtr(v));
162
+ for (len = 0; bridge[len]; len++)
163
+ {
164
+ if (bridge[len] == '/')
165
+ {
166
+ bridge[len] = '\\';
167
+ }
168
+ }
169
+ #endif
170
+ f = fopen(bridge, "rb");
171
+ if (f == NULL)
172
+ {
173
+ return -1;
174
+ }
175
+ len = fread(buff, 1, sizeof(buff), f);
176
+ fclose(f);
177
+ rjb_rbridge = (*jenv)->DefineClass(jenv,
178
+ "jp/co/infoseek/hp/arton/rjb/RBridge", iloader, buff, len);
179
+ if (rjb_rbridge == NULL)
180
+ {
181
+ rjb_check_exception(jenv, 1);
182
+ }
183
+ rjb_register_bridge = (*jenv)->GetMethodID(jenv, rjb_rbridge, "register",
184
+ "(Ljava/lang/Class;)Ljava/lang/Object;");
185
+ nmethod[0].name = "call";
186
+ nmethod[0].signature = "(Ljava/lang/String;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;";
187
+ nmethod[0].fnPtr = Java_jp_co_infoseek_hp_arton_rjb_RBridge_call;
188
+ (*jenv)->RegisterNatives(jenv, rjb_rbridge, nmethod, 1);
189
+ rjb_rbridge = (*jenv)->NewGlobalRef(jenv, rjb_rbridge);
190
+ return 0;
191
+ }
192
+
193
+ int rjb_create_jvm(JNIEnv** pjenv, JavaVMInitArgs* vm_args, char* userpath, VALUE argv)
194
+ {
195
+ static JavaVMOption soptions[] = {
196
+ #if defined(__sparc_v9__) || defined(__sparc__)
197
+ { "-Xusealtsigs", NULL },
198
+ #elif defined(linux) || defined(__linux__)
199
+ { "-Xrs", NULL },
200
+ #elif defined(__APPLE__) && defined(_ARCH_PPC)
201
+ { "-Xrs", NULL },
202
+ #endif
203
+ #if defined(SHOW_JAVAGC)
204
+ { "-verbose:gc", NULL },
205
+ #endif
206
+ { "DUMMY", NULL }, /* for classpath count */
207
+ };
208
+ char* newpath;
209
+ VALUE ptr;
210
+ int len;
211
+ int result;
212
+ GETDEFAULTJAVAVMINITARGS initargs;
213
+ CREATEJAVAVM createjavavm;
214
+ JavaVMOption* options;
215
+ int optlen;
216
+ int i;
217
+ VALUE optval;
218
+
219
+ if (!RTEST(jvmdll))
220
+ {
221
+ if (!load_jvm(JVM_TYPE))
222
+ {
223
+ return -1;
224
+ }
225
+ }
226
+
227
+ if (NIL_P(getdefaultjavavminitargsfunc))
228
+ {
229
+ return -1;
230
+ }
231
+ initargs = (GETDEFAULTJAVAVMINITARGS)NUM2ULONG(getdefaultjavavminitargsfunc);
232
+ result = initargs(vm_args);
233
+ if (0 > result)
234
+ {
235
+ return result;
236
+ }
237
+ len = strlen(userpath);
238
+ if (getenv("CLASSPATH"))
239
+ {
240
+ len += strlen(getenv("CLASSPATH"));
241
+ }
242
+ newpath = ALLOCA_N(char, len + 32);
243
+ if (getenv("CLASSPATH"))
244
+ {
245
+ sprintf(newpath, "-Djava.class.path=%s%c%s",
246
+ userpath, CLASSPATH_SEP, getenv("CLASSPATH"));
247
+ }
248
+ else
249
+ {
250
+ sprintf(newpath, "-Djava.class.path=%s", userpath);
251
+ }
252
+ optlen = 0;
253
+ if (!NIL_P(argv))
254
+ {
255
+ optlen += RARRAY(argv)->len;
256
+ }
257
+ optlen += COUNTOF(soptions);
258
+ options = ALLOCA_N(JavaVMOption, optlen);
259
+ options->optionString = newpath;
260
+ options->extraInfo = NULL;
261
+ for (i = 1; i < COUNTOF(soptions); i++)
262
+ {
263
+ *(options + i) = soptions[i - 1];
264
+ }
265
+ for (; i < optlen; i++)
266
+ {
267
+ optval = rb_ary_entry(argv, i - COUNTOF(soptions));
268
+ Check_Type(optval, T_STRING);
269
+ (options + i)->optionString = StringValueCStr(optval);
270
+ (options + i)->extraInfo = NULL;
271
+ }
272
+ vm_args->nOptions = optlen;
273
+ vm_args->options = options;
274
+ vm_args->ignoreUnrecognized = JNI_TRUE;
275
+ if (NIL_P(createjavavmfunc))
276
+ {
277
+ return -1;
278
+ }
279
+ createjavavm = (CREATEJAVAVM)NUM2ULONG(createjavavmfunc);
280
+ result = createjavavm(&rjb_jvm, pjenv, vm_args);
281
+ if (!result)
282
+ {
283
+ result = load_bridge(*pjenv);
284
+ }
285
+ return result;
286
+ }
287
+