rjb 1.5.5 → 1.5.9
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.
- checksums.yaml +5 -5
- data/ChangeLog +26 -0
- data/ext/{depend → depend.erb} +1 -1
- data/ext/extconf.h +1 -1
- data/ext/extconf.rb +10 -0
- data/ext/load.c +4 -0
- data/ext/rjb.c +3 -3
- data/ext/rjbexception.c +16 -13
- data/test/anon-test-50.rb +13 -0
- data/test/anon-test-60.rb +17 -0
- data/test/anon.rb +23 -0
- data/test/b.rb +13 -0
- data/test/test.rb +14 -0
- data/test/x.rb +10 -0
- metadata +18 -11
- data/README.md +0 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b8eddc0f7bf9505a5f48e1098dd18f0133253986978599c40e5c39ce6cc48b90
|
4
|
+
data.tar.gz: 880d819371d1cb1c738c2db0c0395873d86391ecef8b056c7597aacf930598ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad9b557b9ff3d9091663df6041b63672ba96a2e192f23deba2dbe6dfe94edf09f36176e8894b2e71c8194f68e6f4e23b1e67c9a7064c52c5dea5ce0723be9e14
|
7
|
+
data.tar.gz: 7da7f62f72373a83ef662ee62cd37c7fdac28a52c6fc059af337970a7249103858442c304b139945118371c2893ac6057404f619016d4cff758a5aabaffd80f2
|
data/ChangeLog
CHANGED
@@ -1,3 +1,29 @@
|
|
1
|
+
Sun Feb 17 2019 lamby / arton
|
2
|
+
* ext/rjb.c
|
3
|
+
RJB_VERSION -> 1.5.9
|
4
|
+
* ext/depend.erb
|
5
|
+
it set javah line by ERB
|
6
|
+
* ext/extconf.rb
|
7
|
+
change javah to javac -h if it does not exist
|
8
|
+
* ext/depend
|
9
|
+
replaced by depend.erb
|
10
|
+
Thu Jan 17 2019 arton
|
11
|
+
* ext/rjbexception.c
|
12
|
+
restore method_missing for the exception class
|
13
|
+
* ext/rjb.c
|
14
|
+
RJB_VERSION -> 1.5.8
|
15
|
+
* test/test.rb
|
16
|
+
add #60 test
|
17
|
+
Fri Dec 28 2018 arton
|
18
|
+
* ext/rjbexception.c
|
19
|
+
fix #60; stable java derived exception class for raise
|
20
|
+
* ext/rjb.c
|
21
|
+
RJB_VERSION -> 1.5.7
|
22
|
+
Thu Dec 27 2018 sean-npu
|
23
|
+
* ext/load.c
|
24
|
+
support aarch64
|
25
|
+
* ext/rjb.c
|
26
|
+
RJB_VERSION -> 1.5.6
|
1
27
|
Sun Oct 30 arbox, maxberger and arton
|
2
28
|
*Rakefile
|
3
29
|
*rjb.gemspec
|
data/ext/{depend → depend.erb}
RENAMED
@@ -3,7 +3,7 @@ rjb.o : rjb.c jp_co_infoseek_hp_arton_rjb_RBridge.h riconv.h rjb.h
|
|
3
3
|
rjbexception.o : rjbexception.c jp_co_infoseek_hp_arton_rjb_RBridge.h riconv.h rjb.h
|
4
4
|
load.o : load.c jp_co_infoseek_hp_arton_rjb_RBridge.h
|
5
5
|
jp_co_infoseek_hp_arton_rjb_RBridge.h : jniwrap.h ../data/rjb/jp/co/infoseek/hp/arton/rjb/RBridge.class
|
6
|
-
javah
|
6
|
+
<%= javah %>
|
7
7
|
../data/rjb/jp/co/infoseek/hp/arton/rjb/RBridge.class : RBridge.java
|
8
8
|
mkdir -p ../data/rjb/jp/co/infoseek/hp/arton/rjb
|
9
9
|
javac -d ../data/rjb RBridge.java
|
data/ext/extconf.h
CHANGED
data/ext/extconf.rb
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
# $Date: $
|
5
5
|
#----------------------------------
|
6
6
|
require 'mkmf'
|
7
|
+
require 'erb'
|
7
8
|
|
8
9
|
class Path
|
9
10
|
|
@@ -74,4 +75,13 @@ when /mswin32/
|
|
74
75
|
when /cygwin/, /mingw/
|
75
76
|
$defs << '-DNONAMELESSUNION'
|
76
77
|
end
|
78
|
+
|
79
|
+
if find_executable('javah')
|
80
|
+
javah = 'javah -classpath ../data/rjb jp.co.infoseek.hp.arton.rjb.RBridge'
|
81
|
+
else
|
82
|
+
javah = 'javac -h . -classpath ../data/rjb RBridge.java'
|
83
|
+
end
|
84
|
+
File.open('depend', 'w') do |fout|
|
85
|
+
fout.write ERB.new(IO::read('depend.erb')).result
|
86
|
+
end
|
77
87
|
create_rjb_makefile
|
data/ext/load.c
CHANGED
data/ext/rjb.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
* Rjb - Ruby <-> Java Bridge
|
3
|
-
* Copyright(c) 2004,2005,2006,2007,2008,2009,2010,2011,2012,2014-2016 arton
|
3
|
+
* Copyright(c) 2004,2005,2006,2007,2008,2009,2010,2011,2012,2014-2016,2018 arton
|
4
4
|
*
|
5
5
|
* This library is free software; you can redistribute it and/or
|
6
6
|
* modify it under the terms of the GNU Lesser General Public
|
@@ -14,7 +14,7 @@
|
|
14
14
|
*
|
15
15
|
*/
|
16
16
|
|
17
|
-
#define RJB_VERSION "1.5.
|
17
|
+
#define RJB_VERSION "1.5.9"
|
18
18
|
|
19
19
|
#include "ruby.h"
|
20
20
|
#include "extconf.h"
|
@@ -601,7 +601,7 @@ static VALUE jv2rv_withprim(JNIEnv* jenv, jobject o)
|
|
601
601
|
jv.j = (*jenv)->CallLongMethod(jenv, o, jpcvt[i].to_prim_id);
|
602
602
|
break;
|
603
603
|
default:
|
604
|
-
rb_raise(rb_eRuntimeError, "no
|
604
|
+
rb_raise(rb_eRuntimeError, "no converter defined(%d)", i);
|
605
605
|
break;
|
606
606
|
}
|
607
607
|
(*jenv)->DeleteLocalRef(jenv, o);
|
data/ext/rjbexception.c
CHANGED
@@ -34,13 +34,16 @@ static VALUE missing_delegate(int argc, VALUE* argv, VALUE self)
|
|
34
34
|
|
35
35
|
static VALUE get_cause(VALUE self)
|
36
36
|
{
|
37
|
-
|
37
|
+
return rb_funcall(rb_ivar_get(self, rb_intern("@cause")), rb_intern("cause"), 0);
|
38
38
|
}
|
39
39
|
|
40
|
-
static VALUE
|
40
|
+
static VALUE ex_respond_to(int argc, VALUE* argv, VALUE self)
|
41
41
|
{
|
42
|
-
|
43
|
-
|
42
|
+
if (argc < 1 || argc > 2)
|
43
|
+
{
|
44
|
+
rb_raise(rb_eArgError, "respond_to? require 1 or 2 arguments");
|
45
|
+
}
|
46
|
+
return rb_to_id(argv[0]) == rb_intern("to_str") ? Qfalse : Qtrue;
|
44
47
|
}
|
45
48
|
|
46
49
|
/*
|
@@ -70,18 +73,18 @@ VALUE rjb_get_exception_class(JNIEnv* jenv, jstring str)
|
|
70
73
|
rexp = rb_hash_aref(rjb_loaded_classes, cname);
|
71
74
|
if (rexp == Qnil)
|
72
75
|
{
|
73
|
-
|
74
|
-
|
76
|
+
rexp = rb_define_class(pcls, rb_eStandardError);
|
77
|
+
rb_define_method(rexp, "cause", get_cause, 0);
|
75
78
|
rb_define_method(rexp, "method_missing", missing_delegate, -1);
|
76
|
-
rb_define_method(rexp, "
|
79
|
+
rb_define_method(rexp, "respond_to?", ex_respond_to, -1);
|
77
80
|
#if defined(HAVE_RB_HASH_ASET) || defined(RUBINIUS)
|
78
81
|
rb_hash_aset(rjb_loaded_classes, cname, rexp);
|
79
82
|
#else
|
80
|
-
#ifdef RHASH_TBL
|
81
|
-
|
82
|
-
#else
|
83
|
-
|
84
|
-
#endif
|
83
|
+
#ifdef RHASH_TBL
|
84
|
+
st_insert(RHASH_TBL(rjb_loaded_classes), cname, rexp);
|
85
|
+
#else
|
86
|
+
st_insert(RHASH(rjb_loaded_classes)->tbl, cname, rexp);
|
87
|
+
#endif
|
85
88
|
#endif
|
86
89
|
|
87
90
|
}
|
@@ -140,7 +143,7 @@ void rjb_check_exception(JNIEnv* jenv, int t)
|
|
140
143
|
(*jenv)->ExceptionClear(jenv);
|
141
144
|
if(1)
|
142
145
|
{
|
143
|
-
|
146
|
+
char* msg = (char*)"unknown exception";
|
144
147
|
jclass cls = (*jenv)->GetObjectClass(jenv, exp);
|
145
148
|
jstring str = (*jenv)->CallObjectMethod(jenv, exp, rjb_throwable_getMessage);
|
146
149
|
if (str)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rjb'
|
2
|
+
Rjb::load
|
3
|
+
begin
|
4
|
+
Rjb::throw('java.lang.NumberFormatException', 'test')
|
5
|
+
Rjb::throw(Rjb::import('java.lang.NumberFormatException').new('test'))
|
6
|
+
rescue NumberFormatException => e
|
7
|
+
puts "I expect a NumberFormatException to be thrown"
|
8
|
+
rescue Exception => e
|
9
|
+
puts "I at least expect *some* excetpion to be thrown"
|
10
|
+
else
|
11
|
+
puts "Unexpectedly no exception is thrown"
|
12
|
+
end
|
13
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rjb'
|
2
|
+
Rjb::load
|
3
|
+
begin
|
4
|
+
Rjb::import('java.lang.Integer').parseInt('x')
|
5
|
+
rescue => e
|
6
|
+
begin
|
7
|
+
raise e
|
8
|
+
rescue => f
|
9
|
+
if e.class == f.class
|
10
|
+
puts "I expect the equality to be true"
|
11
|
+
else
|
12
|
+
puts "Unexpectedly the re-raised Java exception has changed " +
|
13
|
+
"from a #{e.class} into a #{f.class}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
data/test/anon.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rjb'
|
2
|
+
Rjb::load
|
3
|
+
begin
|
4
|
+
Rjb::import('java.lang.Integer').parseInt('x')
|
5
|
+
rescue NumberFormatException => e
|
6
|
+
puts e.class
|
7
|
+
puts e.message
|
8
|
+
begin
|
9
|
+
puts (StandardError === e).to_s
|
10
|
+
raise e
|
11
|
+
rescue => f
|
12
|
+
puts f.class
|
13
|
+
puts f.message
|
14
|
+
puts f.cause.inspect
|
15
|
+
puts f.exception.inspect
|
16
|
+
if e.class == f.class
|
17
|
+
puts "I expect the equality to be true"
|
18
|
+
else
|
19
|
+
puts "Unexpectedly the re-raised Java exception has changed " +
|
20
|
+
"from a #{e.class} into a #{f.class}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/test/b.rb
ADDED
data/test/test.rb
CHANGED
@@ -933,5 +933,19 @@ class TestRjb < Test::Unit::TestCase
|
|
933
933
|
assert_equal org.size, len
|
934
934
|
assert_equal org, buffer[0...len]
|
935
935
|
end
|
936
|
+
|
937
|
+
def test_re_raise
|
938
|
+
begin
|
939
|
+
@jInteger.parseInt('blabla')
|
940
|
+
flunk('no exception')
|
941
|
+
rescue NumberFormatException => e
|
942
|
+
begin
|
943
|
+
raise
|
944
|
+
rescue => e
|
945
|
+
assert_equal(NumberFormatException, e.class)
|
946
|
+
# OK
|
947
|
+
end
|
948
|
+
end
|
949
|
+
end
|
936
950
|
end
|
937
951
|
|
data/test/x.rb
ADDED
metadata
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rjb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- arton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: RJB is a
|
13
|
+
description: 'RJB is a bridge program that connect between Ruby and Java with Java
|
14
14
|
Native Interface.
|
15
|
+
|
16
|
+
'
|
15
17
|
email: artonx@gmail.com
|
16
18
|
executables: []
|
17
19
|
extensions:
|
@@ -20,10 +22,9 @@ extra_rdoc_files: []
|
|
20
22
|
files:
|
21
23
|
- COPYING
|
22
24
|
- ChangeLog
|
23
|
-
- README.md
|
24
25
|
- data/rjb/jp/co/infoseek/hp/arton/rjb/RBridge.class
|
25
26
|
- ext/RBridge.java
|
26
|
-
- ext/depend
|
27
|
+
- ext/depend.erb
|
27
28
|
- ext/extconf.h
|
28
29
|
- ext/extconf.rb
|
29
30
|
- ext/jniwrap.h
|
@@ -43,6 +44,10 @@ files:
|
|
43
44
|
- readme.txt
|
44
45
|
- samples/filechooser.rb
|
45
46
|
- samples/unzip.rb
|
47
|
+
- test/anon-test-50.rb
|
48
|
+
- test/anon-test-60.rb
|
49
|
+
- test/anon.rb
|
50
|
+
- test/b.rb
|
46
51
|
- test/exttest.rb
|
47
52
|
- test/gctest.rb
|
48
53
|
- test/jartest.jar
|
@@ -66,9 +71,10 @@ files:
|
|
66
71
|
- test/test_osxjvm.rb
|
67
72
|
- test/test_osxload.rb
|
68
73
|
- test/test_unload.rb
|
69
|
-
|
74
|
+
- test/x.rb
|
75
|
+
homepage: https://www.artonx.org/collabo/backyard/?RubyJavaBridge
|
70
76
|
licenses:
|
71
|
-
- LGPL
|
77
|
+
- LGPL
|
72
78
|
metadata: {}
|
73
79
|
post_install_message:
|
74
80
|
rdoc_options: []
|
@@ -85,10 +91,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
91
|
- !ruby/object:Gem::Version
|
86
92
|
version: '0'
|
87
93
|
requirements:
|
94
|
+
- none
|
88
95
|
- JDK 5.0
|
89
|
-
|
90
|
-
rubygems_version: 2.6.4
|
96
|
+
rubygems_version: 3.0.1
|
91
97
|
signing_key:
|
92
98
|
specification_version: 4
|
93
|
-
summary: Ruby Java
|
94
|
-
test_files:
|
99
|
+
summary: Ruby Java bridge
|
100
|
+
test_files:
|
101
|
+
- test/test.rb
|
data/README.md
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
# Rjb is Ruby-Java bridge using Java Native Interface.
|
2
|
-
|
3
|
-
The [Ruby Kaigi 2010](http://www.slideshare.net/artonx/j-ruby-kaigi-2010)
|
4
|
-
Presentation on `Rjb`.
|
5
|
-
|
6
|
-
A short [introduction](https://www.artonx.org/collabo/backyard/?RubyJavaBridge)
|
7
|
-
in English.
|
8
|
-
|
9
|
-
Some [examples](https://www.artonx.org/collabo/backyard/?RjbQandA) in
|
10
|
-
Japanese, but the source code is clear for everybody.
|
11
|
-
|
12
|
-
# How to install
|
13
|
-
|
14
|
-
You need to install Java2 sdk, and setup `JAVA_HOME` enviromental
|
15
|
-
varible except for OS X. I assume that OS X's `JAVA_HOME` is reported
|
16
|
-
by calling `/usr/libexec/java_home`.
|
17
|
-
|
18
|
-
This done please proceed with:
|
19
|
-
|
20
|
-
``` bash
|
21
|
-
ruby setup.rb config
|
22
|
-
ruby setup.rb setup
|
23
|
-
```
|
24
|
-
|
25
|
-
``` bash
|
26
|
-
# (in Unix)
|
27
|
-
sudo ruby setup.rb install
|
28
|
-
```
|
29
|
-
|
30
|
-
or
|
31
|
-
|
32
|
-
``` bash
|
33
|
-
# (in win32)
|
34
|
-
ruby setup.rb install
|
35
|
-
```
|
36
|
-
|
37
|
-
# How to test
|
38
|
-
|
39
|
-
On Windows based machines:
|
40
|
-
|
41
|
-
``` bash
|
42
|
-
cd test
|
43
|
-
ruby test.rb
|
44
|
-
```
|
45
|
-
|
46
|
-
On Unix based machines plese see `test/readme.unix`. You need to set
|
47
|
-
`LD_LIBRARY_PATH` environmental variable to run `rjb`.
|
48
|
-
|
49
|
-
# Notice for opening non-ASCII 7bit filename
|
50
|
-
|
51
|
-
If you'll plan to open the non-ascii character named file by Java
|
52
|
-
class through Rjb, it may require to set LC_ALL environment variable
|
53
|
-
in you sciprt.
|
54
|
-
|
55
|
-
For example in Rails, set above line in `production.rb` as your environment:
|
56
|
-
|
57
|
-
``` bash
|
58
|
-
ENV['LC_ALL'] = 'en_us.utf8' # or ja_JP.utf8 etc.
|
59
|
-
```
|
60
|
-
|
61
|
-
cf: http://bugs.sun.com/view_bug.do?bug_id=4733494
|
62
|
-
(Thanks Paul for this information).
|
63
|
-
|
64
|
-
# Contact
|
65
|
-
artonx@yahoo.co.jp
|