rjb 1.3.9 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +24 -0
- data/ext/extconf.h +0 -0
- data/ext/jp_co_infoseek_hp_arton_rjb_RBridge.h +21 -21
- data/ext/rjb.c +46 -16
- data/lib/rjb.rb +2 -0
- data/lib/rjbextension.rb +1 -128
- data/readme.txt +28 -35
- data/test/jartest.rb +24 -0
- data/test/jartest2.jar +0 -0
- data/test/jartest2.rb +23 -0
- data/test/jartest3.rb +28 -0
- data/test/jp/co/infoseek/hp/arton/rjb/IBase.class +0 -0
- data/test/jp/co/infoseek/hp/arton/rjb/Test$TestTypes.class +0 -0
- data/test/jp/co/infoseek/hp/arton/rjb/Test.class +0 -0
- data/test/listtest.rb +56 -0
- data/test/rjbtest.jar +0 -0
- data/test/test_unload.rb +0 -0
- metadata +39 -39
data/ChangeLog
CHANGED
@@ -1,3 +1,27 @@
|
|
1
|
+
Sun Apr 22 arton
|
2
|
+
*ext/rjb.c
|
3
|
+
add Rjb_JavaProxy#initialize_proxy method for preparing proxy instance.
|
4
|
+
RJB_VERSION -> 1.4.0
|
5
|
+
*lib/rjb
|
6
|
+
add rjb own directory
|
7
|
+
*lib/rjbextension.rb
|
8
|
+
move contents into rjb/extension.rb
|
9
|
+
*lib/rjb/extension.rb
|
10
|
+
extension library to handle package name easily.
|
11
|
+
*lib/rjb/list.rb
|
12
|
+
implements each method for Iterable and Iterator.
|
13
|
+
Sun Apr 22 arton
|
14
|
+
*ext/rjb.c
|
15
|
+
use URLClassLoader#addJar for Rjb::add_jar method.
|
16
|
+
It accepts unhierarchic load order.
|
17
|
+
*test/jartest2.jar
|
18
|
+
for test Rjb::add_jar. this jar contains a class that extends class in jartest.jar
|
19
|
+
*test/jartest.rb
|
20
|
+
testing Rjb::add_jar, first jartest2.jar then jartest.jar
|
21
|
+
*test/jartest2.rb
|
22
|
+
testing Rjb::add_jar for an array.
|
23
|
+
*test/jartest3.rb
|
24
|
+
testing Rjb::add_jar in NoClassDefError condition.
|
1
25
|
Sat Jan 28 arton
|
2
26
|
*ext/rjb.c
|
3
27
|
RJB_VERSION -> 1.3.9
|
data/ext/extconf.h
CHANGED
File without changes
|
@@ -1,21 +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
|
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/rjb.c
CHANGED
@@ -12,10 +12,10 @@
|
|
12
12
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
13
|
* Lesser General Public License for more details.
|
14
14
|
*
|
15
|
-
* $Id: rjb.c
|
15
|
+
* $Id: rjb.c 187 2012-04-22 12:35:49Z arton $
|
16
16
|
*/
|
17
17
|
|
18
|
-
#define RJB_VERSION "1.
|
18
|
+
#define RJB_VERSION "1.4.0"
|
19
19
|
|
20
20
|
#include "ruby.h"
|
21
21
|
#include "extconf.h"
|
@@ -86,6 +86,7 @@ static VALUE rjbb;
|
|
86
86
|
static VALUE rjba;
|
87
87
|
|
88
88
|
static ID user_initialize;
|
89
|
+
static ID initialize_proxy;
|
89
90
|
static ID cvar_classpath;
|
90
91
|
static ID anonymousblock;
|
91
92
|
static ID id_call;
|
@@ -132,6 +133,7 @@ static jclass j_url_loader;
|
|
132
133
|
static jobject url_loader;
|
133
134
|
static jmethodID url_loader_new;
|
134
135
|
static jmethodID url_geturls;
|
136
|
+
static jmethodID url_add_url;
|
135
137
|
/* URL global reference */
|
136
138
|
static jclass j_url;
|
137
139
|
static jmethodID url_new;
|
@@ -2099,7 +2101,7 @@ static VALUE rjb_i_prepare_proxy(VALUE self)
|
|
2099
2101
|
|
2100
2102
|
static VALUE register_instance(JNIEnv* jenv, VALUE klass, struct jv_data* org, jobject obj)
|
2101
2103
|
{
|
2102
|
-
VALUE v;
|
2104
|
+
volatile VALUE v;
|
2103
2105
|
VALUE iproc;
|
2104
2106
|
struct jvi_data* ptr = ALLOC(struct jvi_data);
|
2105
2107
|
memset(ptr, 0, sizeof(struct jvi_data));
|
@@ -2114,6 +2116,7 @@ static VALUE register_instance(JNIEnv* jenv, VALUE klass, struct jv_data* org, j
|
|
2114
2116
|
rb_ivar_set(v, user_initialize, iproc);
|
2115
2117
|
rb_funcall(v, rb_intern("_prepare_proxy"), 0, 0);
|
2116
2118
|
}
|
2119
|
+
rb_funcall(v, initialize_proxy, 0, 0);
|
2117
2120
|
return v;
|
2118
2121
|
}
|
2119
2122
|
|
@@ -2559,27 +2562,53 @@ static VALUE rjb_s_add_jar(VALUE self, VALUE jarname)
|
|
2559
2562
|
"([Ljava/net/URL;Ljava/lang/ClassLoader;)V");
|
2560
2563
|
RJB_LOAD_METHOD(url_geturls, j_url_loader, "getURLs",
|
2561
2564
|
"()[Ljava/net/URL;");
|
2565
|
+
RJB_LOAD_METHOD(url_add_url, j_url_loader, "addURL",
|
2566
|
+
"(Ljava/net/URL;)V");
|
2562
2567
|
}
|
2563
|
-
|
2564
|
-
rjb_check_exception(jenv, 0);
|
2565
|
-
if (!count)
|
2568
|
+
if (!url_loader)
|
2566
2569
|
{
|
2567
|
-
(*jenv)->
|
2570
|
+
args[0].l = (*jenv)->NewObjectArray(jenv, (count == 0) ? 1 : count, j_url, NULL);
|
2571
|
+
rjb_check_exception(jenv, 0);
|
2572
|
+
if (!count)
|
2573
|
+
{
|
2574
|
+
(*jenv)->SetObjectArrayElement(jenv, args[0].l, 0,
|
2568
2575
|
conv_jarname_to_url(jenv, jarname));
|
2576
|
+
}
|
2577
|
+
else
|
2578
|
+
{
|
2579
|
+
for (i = 0; i < count; i++) {
|
2580
|
+
(*jenv)->SetObjectArrayElement(jenv, args[0].l, i,
|
2581
|
+
conv_jarname_to_url(jenv, rb_ary_entry(jarname, i)));
|
2582
|
+
}
|
2583
|
+
}
|
2584
|
+
rjb_check_exception(jenv, 0);
|
2585
|
+
args[1].l = get_class_loader(jenv);
|
2586
|
+
url_loader = (*jenv)->NewObjectA(jenv, j_url_loader, url_loader_new, args);
|
2587
|
+
rjb_check_exception(jenv, 0);
|
2588
|
+
(*jenv)->NewGlobalRef(jenv, url_loader);
|
2589
|
+
(*jenv)->DeleteLocalRef(jenv, args[0].l);
|
2569
2590
|
}
|
2570
2591
|
else
|
2571
2592
|
{
|
2572
|
-
|
2573
|
-
|
2574
|
-
|
2593
|
+
jvalue v;
|
2594
|
+
if (count)
|
2595
|
+
{
|
2596
|
+
for (i = 0; i < count; i++)
|
2597
|
+
{
|
2598
|
+
v.l = conv_jarname_to_url(jenv, rb_ary_entry(jarname, i));
|
2599
|
+
(*jenv)->CallObjectMethod(jenv, url_loader, url_add_url, v);
|
2600
|
+
rjb_check_exception(jenv, 0);
|
2601
|
+
(*jenv)->DeleteLocalRef(jenv, v.l);
|
2602
|
+
}
|
2603
|
+
}
|
2604
|
+
else
|
2605
|
+
{
|
2606
|
+
v.l = conv_jarname_to_url(jenv, jarname);
|
2607
|
+
(*jenv)->CallObjectMethod(jenv, url_loader, url_add_url, v);
|
2608
|
+
rjb_check_exception(jenv, 0);
|
2609
|
+
(*jenv)->DeleteLocalRef(jenv, v.l);
|
2575
2610
|
}
|
2576
2611
|
}
|
2577
|
-
rjb_check_exception(jenv, 0);
|
2578
|
-
args[1].l = get_class_loader(jenv);
|
2579
|
-
url_loader = (*jenv)->NewObjectA(jenv, j_url_loader, url_loader_new, args);
|
2580
|
-
rjb_check_exception(jenv, 0);
|
2581
|
-
(*jenv)->NewGlobalRef(jenv, url_loader);
|
2582
|
-
(*jenv)->DeleteLocalRef(jenv, args[0].l);
|
2583
2612
|
return Qtrue;
|
2584
2613
|
}
|
2585
2614
|
|
@@ -3159,6 +3188,7 @@ void Init_rjbcore()
|
|
3159
3188
|
proxies = rb_ary_new();
|
3160
3189
|
rb_global_variable(&proxies);
|
3161
3190
|
user_initialize = rb_intern(USER_INITIALIZE);
|
3191
|
+
initialize_proxy = rb_intern("initialize_proxy");
|
3162
3192
|
|
3163
3193
|
rjb = rb_define_module("Rjb");
|
3164
3194
|
rb_define_module_function(rjb, "load", rjb_s_load, -1);
|
data/lib/rjb.rb
CHANGED
data/lib/rjbextension.rb
CHANGED
@@ -1,128 +1 @@
|
|
1
|
-
|
2
|
-
Copyright(c) 2010 arton
|
3
|
-
|
4
|
-
This library is free software; you can redistribute it and/or
|
5
|
-
modify it under the terms of the GNU Lesser General Public
|
6
|
-
License as published by the Free Software Foundation; either
|
7
|
-
version 2.1 of the License, or (at your option) any later version.
|
8
|
-
|
9
|
-
This library is distributed in the hope that it will be useful,
|
10
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
-
Lesser General Public License for more details.
|
13
|
-
|
14
|
-
$Id: rjbextension.rb 147 2010-10-23 05:10:33Z arton $
|
15
|
-
|
16
|
-
This file is from Andreas Ronge project neo4j
|
17
|
-
http://github.com/andreasronge/neo4j/blob/rjb/lib/rjb_ext.rb
|
18
|
-
|
19
|
-
Copyright (c) 2008 Andreas Ronge
|
20
|
-
|
21
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
22
|
-
of this software and associated documentation files (the "Software"), to deal
|
23
|
-
in the Software without restriction, including without limitation the rights
|
24
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
25
|
-
copies of the Software, and to permit persons to whom the Software is
|
26
|
-
furnished to do so, subject to the following conditions:
|
27
|
-
|
28
|
-
The above copyright notice and this permission notice shall be included in
|
29
|
-
all copies or substantial portions of the Software.
|
30
|
-
|
31
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
32
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
33
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
34
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
35
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
36
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
37
|
-
THE SOFTWARE.
|
38
|
-
=end
|
39
|
-
|
40
|
-
# Loads the JVM with the given <tt>classpath</tt> and arguments to the jre.
|
41
|
-
# All needed .jars should be included in <tt>classpath</tt>.
|
42
|
-
|
43
|
-
module Kernel
|
44
|
-
alias rjb_original_require require
|
45
|
-
|
46
|
-
def require(path)
|
47
|
-
rjb_original_require(path)
|
48
|
-
rescue LoadError
|
49
|
-
# check that it's not a jar file
|
50
|
-
raise unless path =~ /\.jar/
|
51
|
-
|
52
|
-
# This will maybe use the wrong jar file from a previous version of the GEM
|
53
|
-
# puts "LOAD PATH #{$LOAD_PATH}"
|
54
|
-
found_path = $LOAD_PATH.reverse.find{|p| File.exist?(File.join(p,path))}
|
55
|
-
raise unless found_path
|
56
|
-
|
57
|
-
abs_path = File.join(found_path, path)
|
58
|
-
# check that the file exists
|
59
|
-
raise unless File.exist?(abs_path)
|
60
|
-
|
61
|
-
# try to load it using RJB
|
62
|
-
if Rjb::loaded?
|
63
|
-
Rjb::add_jar abs_path
|
64
|
-
else
|
65
|
-
Rjb::add_classpath abs_path
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def load_jvm(jargs = [])
|
70
|
-
return if Rjb::loaded?
|
71
|
-
classpath = ENV['CLASSPATH'] ||= ''
|
72
|
-
Rjb::load(classpath, jargs)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
class JavaPackage
|
77
|
-
|
78
|
-
def initialize(pack_name, parent_pack = nil)
|
79
|
-
@pack_name = pack_name
|
80
|
-
@parent_pack = parent_pack
|
81
|
-
@cache = {}
|
82
|
-
end
|
83
|
-
|
84
|
-
def method_missing(m, *args)
|
85
|
-
# return if possible old module/class
|
86
|
-
@cache[m] ||= create_package_or_class(m)
|
87
|
-
end
|
88
|
-
def create_package_or_class(m)
|
89
|
-
method = m.to_s
|
90
|
-
if class?(method)
|
91
|
-
Rjb::import("#{self}.#{method}")
|
92
|
-
else
|
93
|
-
JavaPackage.new(method, self)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def to_s
|
98
|
-
if @parent_pack
|
99
|
-
"#{@parent_pack.to_s}.#@pack_name"
|
100
|
-
else
|
101
|
-
"#@pack_name"
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def class?(a)
|
106
|
-
first_letter = a[0,1]
|
107
|
-
first_letter >= 'A' && first_letter <= 'Z'
|
108
|
-
end
|
109
|
-
|
110
|
-
@@cache = {}
|
111
|
-
def self.new(pack_name, parent_pack = nil)
|
112
|
-
@@cache[pack_name] ||= super
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
module RjbConf
|
117
|
-
# make them as singleton
|
118
|
-
ORG = JavaPackage.new('org')
|
119
|
-
JAVA = JavaPackage.new('java')
|
120
|
-
end
|
121
|
-
|
122
|
-
def org
|
123
|
-
RjbConf::ORG
|
124
|
-
end
|
125
|
-
|
126
|
-
def java
|
127
|
-
RjbConf::JAVA
|
128
|
-
end
|
1
|
+
require 'rjb/extension'
|
data/readme.txt
CHANGED
@@ -1,35 +1,28 @@
|
|
1
|
-
Rjb is Ruby-Java bridge using Java Native Interface.
|
2
|
-
|
3
|
-
How to install
|
4
|
-
|
5
|
-
you need to install Java2 sdk, and setup JAVA_HOME enviromental varible except for OS X.
|
6
|
-
I assume that OS X's JAVA_HOME is fixed as '/System/Library/Frameworks/JavaVM.framework'.
|
7
|
-
|
8
|
-
then,
|
9
|
-
|
10
|
-
ruby setup.rb config
|
11
|
-
ruby setup.rb setup
|
12
|
-
|
13
|
-
(in Unix)
|
14
|
-
sudo ruby setup.rb install
|
15
|
-
or
|
16
|
-
(in win32)
|
17
|
-
ruby setup.rb install
|
18
|
-
|
19
|
-
How to test
|
20
|
-
in Win32
|
21
|
-
cd test
|
22
|
-
ruby test.rb
|
23
|
-
|
24
|
-
in Unix
|
25
|
-
see test/readme.unix
|
26
|
-
you must set LD_LIBRARY_PATH environmental variable to run rjb.
|
27
|
-
|
28
|
-
|
29
|
-
If you'll plan to open the non-ascii character named file by Java class through Rjb, it may require to set LC_ALL environment variable in you sciprt.
|
30
|
-
For example in Rails, set above line in production.rb as your environment.
|
31
|
-
ENV['LC_ALL'] = 'en_us.utf8' # or ja_JP.utf8 etc.
|
32
|
-
cf: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4733494
|
33
|
-
(Thanks Paul for this information).
|
34
|
-
|
35
|
-
artonx@yahoo.co.jp
|
1
|
+
Rjb is Ruby-Java bridge using Java Native Interface.
|
2
|
+
|
3
|
+
How to install
|
4
|
+
|
5
|
+
you need to install Java2 sdk, and setup JAVA_HOME enviromental varible except for OS X.
|
6
|
+
I assume that OS X's JAVA_HOME is fixed as '/System/Library/Frameworks/JavaVM.framework'.
|
7
|
+
|
8
|
+
then,
|
9
|
+
|
10
|
+
ruby setup.rb config
|
11
|
+
ruby setup.rb setup
|
12
|
+
|
13
|
+
(in Unix)
|
14
|
+
sudo ruby setup.rb install
|
15
|
+
or
|
16
|
+
(in win32)
|
17
|
+
ruby setup.rb install
|
18
|
+
|
19
|
+
How to test
|
20
|
+
in Win32
|
21
|
+
cd test
|
22
|
+
ruby test.rb
|
23
|
+
|
24
|
+
in Unix
|
25
|
+
see test/readme.unix
|
26
|
+
you must set LD_LIBRARY_PATH environmental variable to run rjb.
|
27
|
+
|
28
|
+
artonx@yahoo.co.jp
|
data/test/jartest.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/local/env ruby -Ku
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rjb'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rjb'
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
class JarTest < Test::Unit::TestCase
|
13
|
+
include Rjb
|
14
|
+
|
15
|
+
def setup
|
16
|
+
Rjb::load()
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_depends
|
20
|
+
add_jar(File.expand_path('./jartest2.jar'))
|
21
|
+
add_jar(File.expand_path('./jartest.jar'))
|
22
|
+
assert Rjb::import('jp.co.infoseek.hp.arton.rjb.JarTest2')
|
23
|
+
end
|
24
|
+
end
|
data/test/jartest2.jar
ADDED
Binary file
|
data/test/jartest2.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/local/env ruby -Ku
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rjb'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rjb'
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
class JarTest < Test::Unit::TestCase
|
13
|
+
include Rjb
|
14
|
+
|
15
|
+
def setup
|
16
|
+
Rjb::load()
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_depends
|
20
|
+
add_jar([File.expand_path('./jartest2.jar'), File.expand_path('./jartest.jar')])
|
21
|
+
assert Rjb::import('jp.co.infoseek.hp.arton.rjb.JarTest2')
|
22
|
+
end
|
23
|
+
end
|
data/test/jartest3.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/local/env ruby -Ku
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rjb'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rjb'
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
class JarTest < Test::Unit::TestCase
|
13
|
+
include Rjb
|
14
|
+
|
15
|
+
def setup
|
16
|
+
Rjb::load()
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_depends
|
20
|
+
add_jar(File.expand_path('./jartest2.jar'))
|
21
|
+
begin
|
22
|
+
Rjb::import('jp.co.infoseek.hp.arton.rjb.JarTest2')
|
23
|
+
fail 'no exception'
|
24
|
+
rescue NoClassDefFoundError
|
25
|
+
assert true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
data/test/listtest.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/usr/local/env ruby -Ku
|
2
|
+
# encoding: utf-8
|
3
|
+
=begin
|
4
|
+
Copyright(c) 2012 arton
|
5
|
+
=end
|
6
|
+
|
7
|
+
begin
|
8
|
+
require 'rjb/list'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rubygems'
|
11
|
+
require 'rjb/list'
|
12
|
+
end
|
13
|
+
require 'test/unit'
|
14
|
+
require 'fileutils'
|
15
|
+
|
16
|
+
class ListTest < Test::Unit::TestCase
|
17
|
+
include Rjb
|
18
|
+
def test_create
|
19
|
+
ja = import('java.util.ArrayList')
|
20
|
+
a = ja.new
|
21
|
+
a.add(1)
|
22
|
+
a.add(2)
|
23
|
+
a.add(3)
|
24
|
+
n = 1
|
25
|
+
a.each do |x|
|
26
|
+
assert_equal n, x.intValue
|
27
|
+
n += 1
|
28
|
+
end
|
29
|
+
assert_equal 4, n
|
30
|
+
end
|
31
|
+
def test_returned_proxy
|
32
|
+
ja = import('java.util.Arrays')
|
33
|
+
a = ja.as_list([1, 2, 3])
|
34
|
+
n = 1
|
35
|
+
a.each do |x|
|
36
|
+
assert_equal n, x.intValue
|
37
|
+
n += 1
|
38
|
+
end
|
39
|
+
assert_equal 4, n
|
40
|
+
end
|
41
|
+
def test_iterator
|
42
|
+
ja = import('java.util.Arrays')
|
43
|
+
it = ja.as_list([1, 2, 3]).iterator
|
44
|
+
n = 1
|
45
|
+
it.each do |x|
|
46
|
+
assert_equal n, x.intValue
|
47
|
+
n += 1
|
48
|
+
end
|
49
|
+
assert_equal 4, n
|
50
|
+
end
|
51
|
+
def test_enumerable
|
52
|
+
ja = import('java.util.Arrays')
|
53
|
+
assert_equal 55, ja.as_list((1..10).to_a).inject(0) {|r, e| r + e.intValue}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
data/test/rjbtest.jar
CHANGED
File without changes
|
data/test/test_unload.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,39 +1,36 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rjb
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.4.0
|
4
5
|
prerelease:
|
5
|
-
version: 1.3.9
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- arton
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
date: 2012-01-28 00:00:00 Z
|
12
|
+
date: 2012-04-22 00:00:00.000000000 Z
|
14
13
|
dependencies: []
|
14
|
+
description: ! 'RJB is a bridge program that connect between Ruby and Java with Java
|
15
|
+
Native Interface.
|
15
16
|
|
16
|
-
|
17
|
-
RJB is a bridge program that connect between Ruby and Java with Java Native Interface.
|
18
|
-
|
17
|
+
'
|
19
18
|
email: artonx@gmail.com
|
20
19
|
executables: []
|
21
|
-
|
22
|
-
extensions:
|
20
|
+
extensions:
|
23
21
|
- ext/extconf.rb
|
24
22
|
extra_rdoc_files: []
|
25
|
-
|
26
|
-
files:
|
23
|
+
files:
|
27
24
|
- ext/RBridge.java
|
28
|
-
- ext/load.c
|
29
25
|
- ext/rjbexception.c
|
30
|
-
- ext/riconv.c
|
31
26
|
- ext/rjb.c
|
32
|
-
- ext/
|
33
|
-
- ext/
|
27
|
+
- ext/riconv.c
|
28
|
+
- ext/load.c
|
29
|
+
- ext/rjb.h
|
34
30
|
- ext/extconf.h
|
31
|
+
- ext/jp_co_infoseek_hp_arton_rjb_RBridge.h
|
35
32
|
- ext/jniwrap.h
|
36
|
-
- ext/
|
33
|
+
- ext/riconv.h
|
37
34
|
- ext/depend
|
38
35
|
- data/rjb/jp/co/infoseek/hp/arton/rjb/RBridge.class
|
39
36
|
- lib/rjb.rb
|
@@ -41,49 +38,52 @@ files:
|
|
41
38
|
- samples/filechooser.rb
|
42
39
|
- samples/unzip.rb
|
43
40
|
- test/test.rb
|
44
|
-
- test/exttest.rb
|
45
|
-
- test/test_unload.rb
|
46
41
|
- test/test_osxjvm.rb
|
42
|
+
- test/exttest.rb
|
43
|
+
- test/jartest3.rb
|
44
|
+
- test/jartest2.rb
|
47
45
|
- test/gctest.rb
|
48
|
-
- test/
|
49
|
-
- test/
|
50
|
-
- test/
|
46
|
+
- test/listtest.rb
|
47
|
+
- test/test_unload.rb
|
48
|
+
- test/jartest.rb
|
51
49
|
- test/TwoCaller.class
|
52
50
|
- test/Two.class
|
51
|
+
- test/jp/co/infoseek/hp/arton/rjb/Test$TestTypes.class
|
52
|
+
- test/jp/co/infoseek/hp/arton/rjb/Test.class
|
53
|
+
- test/jp/co/infoseek/hp/arton/rjb/IBase.class
|
54
|
+
- test/jartest2.jar
|
53
55
|
- test/rjbtest.jar
|
54
56
|
- test/jartest.jar
|
55
57
|
- COPYING
|
56
58
|
- ChangeLog
|
57
|
-
- readme.sj
|
58
59
|
- readme.txt
|
60
|
+
- readme.sj
|
59
61
|
- ext/extconf.rb
|
60
62
|
homepage: http://rjb.rubyforge.org/
|
61
63
|
licenses: []
|
62
|
-
|
63
64
|
post_install_message:
|
64
65
|
rdoc_options: []
|
65
|
-
|
66
|
-
require_paths:
|
66
|
+
require_paths:
|
67
67
|
- lib
|
68
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
69
|
none: false
|
70
|
-
requirements:
|
71
|
-
- -
|
72
|
-
- !ruby/object:Gem::Version
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
73
|
version: 1.8.2
|
74
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
75
|
none: false
|
76
|
-
requirements:
|
77
|
-
- -
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version:
|
80
|
-
requirements:
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements:
|
81
81
|
- none
|
82
82
|
- JDK 5.0
|
83
83
|
rubyforge_project: rjb
|
84
|
-
rubygems_version: 1.8.
|
84
|
+
rubygems_version: 1.8.23
|
85
85
|
signing_key:
|
86
86
|
specification_version: 3
|
87
87
|
summary: Ruby Java bridge
|
88
|
-
test_files:
|
88
|
+
test_files:
|
89
89
|
- test/test.rb
|