rjb 1.4.7-x86-mswin32-100

Sign up to get free protection for your applications and to get access to all the features.
data/ext/RBridge.java ADDED
@@ -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
+ }
data/ext/depend ADDED
@@ -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")'
data/ext/extconf.h ADDED
@@ -0,0 +1,7 @@
1
+ #ifndef EXTCONF_H
2
+ #define EXTCONF_H
3
+ #define HAVE_JNI_H 1
4
+ #define HAVE_SETLOCALE 1
5
+ #define HAVE_GETENV 1
6
+ #define RJB_RUBY_VERSION_CODE 193
7
+ #endif
data/ext/jniwrap.h ADDED
@@ -0,0 +1,34 @@
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 181 2012-01-28 05:28:41Z 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
+ #if !defined(__int64)
25
+ typedef long long __int64;
26
+ #endif
27
+ #endif
28
+
29
+ #include <jni.h>
30
+
31
+ #ifdef __cplusplus
32
+ }
33
+ #endif
34
+ #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
data/ext/load.c ADDED
@@ -0,0 +1,438 @@
1
+ /*
2
+ * Rjb - Ruby <-> Java Bridge
3
+ * Copyright(c) 2004,2005,2006,2009,2010,2011 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 180 2011-12-05 16:34:29Z arton $
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
+ #define ALT_JVM_TYPE "classic"
37
+
38
+ #if defined(_WIN32) || defined(__CYGWIN__)
39
+ #if defined(__CYGWIN__)
40
+ #define JVMDLL "%s/jre/bin/%s/jvm.dll"
41
+ #define DIRSEPARATOR '/'
42
+ #else
43
+ #define JVMDLL "%s\\jre\\bin\\%s\\jvm.dll"
44
+ #define DIRSEPARATOR '\\'
45
+ #if defined(_WIN64)
46
+ #undef JVM_TYPE
47
+ #define JVM_TYPE "server"
48
+ #endif
49
+ #endif
50
+ #define CLASSPATH_SEP ';'
51
+ #elif defined(__APPLE__) && defined(__MACH__)
52
+ static char* JVMDLL = "%s/JavaVM";
53
+ #define DIRSEPARATOR '/'
54
+ #define CLASSPATH_SEP ':'
55
+ #define HOME_NAME "/Home"
56
+ #define HOME_NAME_LEN strlen(HOME_NAME)
57
+ #define DEFAULT_HOME "/System/Library/Frameworks/JavaVM.framework"
58
+ #elif defined(_AIX)
59
+ #define ARCH "ppc"
60
+ #undef JVM_TYPE
61
+ #define JVM_TYPE "j9vm"
62
+ #elif defined(__hpux)
63
+ #define JVMDLL "%s/jre/lib/%s/%s/libjvm.sl"
64
+ #define ARCH "PA_RISC"
65
+ #undef JVM_TYPE
66
+ #define JVM_TYPE "server"
67
+ #define DIRSEPARATOR '/'
68
+ #define CLASSPATH_SEP ':'
69
+ #else /* defined(_WIN32) || defined(__CYGWIN__) */
70
+ #if defined(__sparc_v9__)
71
+ #define ARCH "sparcv9"
72
+ #elif defined(__sparc__)
73
+ #define ARCH "sparc"
74
+ #elif defined(__amd64__)
75
+ #define ARCH "amd64"
76
+ #undef JVM_TYPE
77
+ #define JVM_TYPE "server"
78
+ #elif defined(i586) || defined(__i386__)
79
+ #define ARCH "i386"
80
+ #endif
81
+ #ifndef ARCH
82
+ #include <sys/systeminfo.h>
83
+ #endif
84
+ #define JVMDLL "%s/jre/lib/%s/%s/libjvm.so"
85
+ #define DIRSEPARATOR '/'
86
+ #define CLASSPATH_SEP ':'
87
+ #endif
88
+
89
+ #if defined(__APPLE__) && defined(__MACH__)
90
+ static char* CREATEJVM = "JNI_CreateJavaVM";
91
+ static char* GETDEFAULTJVMINITARGS = "JNI_GetDefaultJavaVMInitArgs";
92
+ #else
93
+ #define CREATEJVM "JNI_CreateJavaVM"
94
+ #define GETDEFAULTJVMINITARGS "JNI_GetDefaultJavaVMInitArgs"
95
+ #endif
96
+
97
+ typedef int (JNICALL *GETDEFAULTJAVAVMINITARGS)(void*);
98
+ typedef int (JNICALL *CREATEJAVAVM)(JavaVM**, JNIEnv**, void*);
99
+
100
+
101
+ static VALUE jvmdll = Qnil;
102
+ static VALUE getdefaultjavavminitargsfunc;
103
+ static VALUE createjavavmfunc;
104
+
105
+ static const char* DLLibs[] = { "fiddle", "dl" };
106
+ static const char* DLNames[] = { "Fiddle", "DL" };
107
+
108
+ static VALUE safe_require(VALUE args)
109
+ {
110
+ return rb_require(StringValueCStr(args));
111
+ }
112
+
113
+ static int open_jvm(char* libpath)
114
+ {
115
+ int sstat;
116
+ VALUE* argv;
117
+ size_t i;
118
+ int state;
119
+
120
+ #if defined(RUBINIUS)
121
+ i = 1;
122
+ #else
123
+ i = 0;
124
+ #endif
125
+ for (; i < COUNTOF(DLLibs); i++)
126
+ {
127
+ state = 0;
128
+ rb_protect(safe_require, rb_str_new2(DLLibs[i]), &state);
129
+ #if !defined(RUBINIUS)
130
+ if (state || !rb_const_defined_at(rb_cObject, rb_intern(DLNames[i])))
131
+ {
132
+ if (i > 0)
133
+ {
134
+ rb_raise(rb_eRuntimeError, "Constants DL and Fiddle is not defined.");
135
+ return 0;
136
+ }
137
+ }
138
+ else
139
+ #endif
140
+ {
141
+ sstat = 0;
142
+ argv = ALLOCA_N(VALUE, 4);
143
+ *argv = rb_const_get(rb_cObject, rb_intern(DLNames[i]));
144
+ *(argv + 1) = rb_intern("dlopen");
145
+ *(argv + 2) = 1;
146
+ *(argv + 3) = rb_str_new2(libpath);
147
+ jvmdll = rb_protect(rjb_safe_funcall, (VALUE)argv, &sstat);
148
+ if (!sstat)
149
+ {
150
+ break;
151
+ }
152
+ else if (i > 0)
153
+ {
154
+ return 0;
155
+ }
156
+ }
157
+ }
158
+ /* get function pointers of JNI */
159
+ #if RJB_RUBY_VERSION_CODE < 190
160
+ 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);
161
+ 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);
162
+ #else
163
+ getdefaultjavavminitargsfunc = rb_funcall(jvmdll, rb_intern("[]"), 1, rb_str_new2(GETDEFAULTJVMINITARGS));
164
+ createjavavmfunc = rb_funcall(jvmdll, rb_intern("[]"), 1, rb_str_new2(CREATEJVM));
165
+ #endif
166
+ return 1;
167
+ }
168
+
169
+ #if defined(__APPLE__) && defined(__MACH__)
170
+ static int file_exist(const char* dir, const char* file)
171
+ {
172
+ VALUE path = rb_funcall(rb_cFile, rb_intern("join"), 2,
173
+ rb_str_new2(dir), rb_str_new2(file));
174
+ VALUE ret = rb_funcall(rb_cFile, rb_intern("exist?"), 1, path);
175
+ return RTEST(ret);
176
+ }
177
+ #endif
178
+
179
+ /*
180
+ * not completed, only valid under some circumstances.
181
+ */
182
+ static int load_jvm(const char* jvmtype)
183
+ {
184
+ char* libpath;
185
+ char* java_home;
186
+ char* jh;
187
+
188
+ jh = getenv("JAVA_HOME");
189
+ #if defined(__APPLE__) && defined(__MACH__)
190
+ if (!jh)
191
+ {
192
+ jh = DEFAULT_HOME;
193
+ }
194
+ else
195
+ {
196
+ if (strlen(jh) > HOME_NAME_LEN)
197
+ {
198
+ size_t len = strlen(jh);
199
+ char* p = ALLOCA_N(char, len + 8);
200
+ jh = strcpy(p, jh);
201
+ if (*(jh + len - 1) == '/')
202
+ {
203
+ --len;
204
+ *(jh + len) = '\0';
205
+ }
206
+ if (strcasecmp(jh + len - HOME_NAME_LEN, HOME_NAME) == 0)
207
+ {
208
+ strcpy(p + len, "/..");
209
+ }
210
+ }
211
+ if (!jvmtype && !file_exist(jh, "JavaVM"))
212
+ {
213
+ jh = DEFAULT_HOME;
214
+ }
215
+ }
216
+ #endif
217
+ if (!jh)
218
+ {
219
+ if (RTEST(ruby_verbose))
220
+ {
221
+ fprintf(stderr, "no JAVA_HOME environment\n");
222
+ }
223
+ return 0;
224
+ }
225
+ #if defined(_WIN32)
226
+ if (*jh == '"' && *(jh + strlen(jh) - 1) == '"')
227
+ {
228
+ char* p = ALLOCA_N(char, strlen(jh) + 1);
229
+ strcpy(p, jh + 1);
230
+ *(p + strlen(p) - 1) = '\0';
231
+ jh = p;
232
+ }
233
+ #endif
234
+ java_home = ALLOCA_N(char, strlen(jh) + 1);
235
+ strcpy(java_home, jh);
236
+ if (*(java_home + strlen(jh) - 1) == DIRSEPARATOR)
237
+ {
238
+ *(java_home + strlen(jh) - 1) = '\0';
239
+ }
240
+ #if defined(_WIN32) || defined(__CYGWIN__)
241
+ libpath = ALLOCA_N(char, sizeof(JVMDLL) + strlen(java_home)
242
+ + strlen(jvmtype) + 1);
243
+ sprintf(libpath, JVMDLL, java_home, jvmtype);
244
+ #elif defined(__APPLE__) && defined(__MACH__)
245
+ libpath = ALLOCA_N(char, sizeof(JVMDLL) + strlen(java_home) + 1);
246
+ sprintf(libpath, JVMDLL, java_home);
247
+ #else /* not Windows / MAC OS-X */
248
+ libpath = ALLOCA_N(char, sizeof(JVMDLL) + strlen(java_home)
249
+ + strlen(ARCH) + strlen(jvmtype) + 1);
250
+ sprintf(libpath, JVMDLL, java_home, ARCH, jvmtype);
251
+ #endif
252
+ return open_jvm(libpath);
253
+ }
254
+
255
+ static int load_bridge(JNIEnv* jenv)
256
+ {
257
+ JNINativeMethod nmethod[1];
258
+ jbyte buff[8192];
259
+ char* bridge;
260
+ size_t len;
261
+ FILE* f;
262
+ #if defined(RUBINIUS)
263
+ VALUE v = rb_const_get(rb_cObject, rb_intern("RjbConf"));
264
+ v = rb_const_get(v, rb_intern("BRIDGE_FILE"));
265
+ #else
266
+ VALUE v = rb_const_get_at(rb_const_get(rb_cObject, rb_intern("RjbConf")),
267
+ rb_intern("BRIDGE_FILE"));
268
+ #endif
269
+ bridge = StringValuePtr(v);
270
+ #if defined(DOSISH)
271
+ bridge = ALLOCA_N(char, strlen(bridge) + 8);
272
+ strcpy(bridge, StringValuePtr(v));
273
+ for (len = 0; bridge[len]; len++)
274
+ {
275
+ if (bridge[len] == '/')
276
+ {
277
+ bridge[len] = '\\';
278
+ }
279
+ }
280
+ #endif
281
+ f = fopen(bridge, "rb");
282
+ if (f == NULL)
283
+ {
284
+ return -1;
285
+ }
286
+ len = fread(buff, 1, sizeof(buff), f);
287
+ fclose(f);
288
+ rjb_rbridge = (*jenv)->DefineClass(jenv,
289
+ "jp/co/infoseek/hp/arton/rjb/RBridge", get_systemloader(jenv), buff, len);
290
+ if (rjb_rbridge == NULL)
291
+ {
292
+ rjb_check_exception(jenv, 1);
293
+ }
294
+ rjb_register_bridge = (*jenv)->GetMethodID(jenv, rjb_rbridge, "register",
295
+ "(Ljava/lang/Class;)Ljava/lang/Object;");
296
+ nmethod[0].name = "call";
297
+ nmethod[0].signature = "(Ljava/lang/String;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;";
298
+ nmethod[0].fnPtr = Java_jp_co_infoseek_hp_arton_rjb_RBridge_call;
299
+ (*jenv)->RegisterNatives(jenv, rjb_rbridge, nmethod, 1);
300
+ rjb_rbridge = (*jenv)->NewGlobalRef(jenv, rjb_rbridge);
301
+ return 0;
302
+ }
303
+
304
+ void rjb_unload_vm()
305
+ {
306
+ if (RTEST(jvmdll))
307
+ {
308
+ rb_funcall(jvmdll, rb_intern("close"), 0);
309
+ jvmdll = Qnil;
310
+ }
311
+ }
312
+
313
+ int rjb_create_jvm(JNIEnv** pjenv, JavaVMInitArgs* vm_args, char* userpath, VALUE argv)
314
+ {
315
+ static JavaVMOption soptions[] = {
316
+ #if defined(__sparc_v9__) || defined(__sparc__)
317
+ { "-Xusealtsigs", NULL },
318
+ #elif defined(linux) || defined(__linux__)
319
+ { "-Xrs", NULL },
320
+ #elif defined(__APPLE__) && defined(_ARCH_PPC)
321
+ { "-Xrs", NULL },
322
+ #endif
323
+ #if defined(SHOW_JAVAGC)
324
+ { "-verbose:gc", NULL },
325
+ #endif
326
+ { "DUMMY", NULL }, /* for classpath count */
327
+ };
328
+ char* newpath;
329
+ size_t len;
330
+ int result;
331
+ GETDEFAULTJAVAVMINITARGS initargs;
332
+ CREATEJAVAVM createjavavm;
333
+ JavaVMOption* options;
334
+ size_t optlen;
335
+ size_t i;
336
+ VALUE optval;
337
+
338
+ if (!RTEST(jvmdll))
339
+ {
340
+ char* libjvm = getenv("JVM_LIB");
341
+ #if defined(_WIN32)
342
+ if (libjvm && *libjvm == '"' && *(libjvm + strlen(libjvm) - 1) == '"')
343
+ {
344
+ char* p = ALLOCA_N(char, strlen(libjvm) + 1);
345
+ strcpy(p, libjvm + 1);
346
+ *(p + strlen(p) - 1) = '\0';
347
+ libjvm = p;
348
+ }
349
+ #endif
350
+ if (libjvm == NULL || !open_jvm(libjvm))
351
+ {
352
+ #if defined(__APPLE__) && defined(__MACH__)
353
+ if (!(load_jvm(NULL)))
354
+ {
355
+ JVMDLL = "%s/Libraries/libjvm.dylib";
356
+ CREATEJVM = "JNI_CreateJavaVM_Impl";
357
+ GETDEFAULTJVMINITARGS = "JNI_GetDefaultJavaVMInitArgs_Impl";
358
+ #endif
359
+ if (!(load_jvm(JVM_TYPE) || load_jvm(ALT_JVM_TYPE)))
360
+ {
361
+ return -1;
362
+ }
363
+ #if defined(__APPLE__) && defined(__MACH__)
364
+ }
365
+ #endif
366
+ }
367
+
368
+ #if RJB_RUBY_VERSION_CODE < 190 && !defined(RUBINIUS)
369
+ ruby_errinfo = Qnil;
370
+ #else
371
+ rb_set_errinfo(Qnil);
372
+ #endif
373
+ }
374
+
375
+ if (NIL_P(getdefaultjavavminitargsfunc))
376
+ {
377
+ return -1;
378
+ }
379
+ initargs = (GETDEFAULTJAVAVMINITARGS)NUM2ULONG(getdefaultjavavminitargsfunc);
380
+ result = initargs(vm_args);
381
+ if (0 > result)
382
+ {
383
+ return result;
384
+ }
385
+ len = strlen(userpath);
386
+ if (getenv("CLASSPATH"))
387
+ {
388
+ len += strlen(getenv("CLASSPATH"));
389
+ }
390
+ newpath = ALLOCA_N(char, len + 32);
391
+ if (getenv("CLASSPATH"))
392
+ {
393
+ sprintf(newpath, "-Djava.class.path=%s%c%s",
394
+ userpath, CLASSPATH_SEP, getenv("CLASSPATH"));
395
+ }
396
+ else
397
+ {
398
+ sprintf(newpath, "-Djava.class.path=%s", userpath);
399
+ }
400
+ optlen = 0;
401
+ if (!NIL_P(argv))
402
+ {
403
+ optlen += RARRAY_LEN(argv);
404
+ }
405
+ optlen += COUNTOF(soptions);
406
+ options = ALLOCA_N(JavaVMOption, optlen);
407
+ options->optionString = newpath;
408
+ options->extraInfo = NULL;
409
+ for (i = 1; i < COUNTOF(soptions); i++)
410
+ {
411
+ *(options + i) = soptions[i - 1];
412
+ }
413
+ for (; i < optlen; i++)
414
+ {
415
+ optval = rb_ary_entry(argv, i - COUNTOF(soptions));
416
+ Check_Type(optval, T_STRING);
417
+ (options + i)->optionString = StringValueCStr(optval);
418
+ (options + i)->extraInfo = NULL;
419
+ }
420
+ vm_args->nOptions = (int)optlen;
421
+ vm_args->options = options;
422
+ vm_args->ignoreUnrecognized = JNI_TRUE;
423
+ if (NIL_P(createjavavmfunc))
424
+ {
425
+ return -1;
426
+ }
427
+ createjavavm = (CREATEJAVAVM)NUM2ULONG(createjavavmfunc);
428
+ result = createjavavm(&rjb_jvm, pjenv, vm_args);
429
+ if (!result)
430
+ {
431
+ result = load_bridge(*pjenv);
432
+ if (RTEST(ruby_verbose) && result < 0)
433
+ {
434
+ fprintf(stderr, "failed to load the bridge class\n");
435
+ }
436
+ }
437
+ return result;
438
+ }