rjb 1.2.5 → 1.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +10 -0
- data/ext/load.c +1 -1
- data/ext/rjb.c +3 -3
- data/ext/rjb.h +2 -1
- data/ext/rjbexception.c +14 -2
- data/test/test.rb +2 -1
- metadata +4 -4
data/ChangeLog
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
Thu Jul 22 arton
|
2
|
+
*ext/rjb.c
|
3
|
+
RJB_VERSION -> 1.2.6
|
4
|
+
export jv2rv for rjbexception.c
|
5
|
+
*ext/rjb.h
|
6
|
+
export jv2rv for rjbexception.c
|
7
|
+
*ext/rjbexception.c
|
8
|
+
create and keep java exception object for its properties.
|
9
|
+
*test/test.rb
|
10
|
+
add Exception#cause test
|
1
11
|
Wed Jun 9 arton
|
2
12
|
*ext/load.c
|
3
13
|
accept JAVA_HOME having an extra slash at the end
|
data/ext/load.c
CHANGED
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 126 2010-07-22 13:58:15Z arton $
|
16
16
|
*/
|
17
17
|
|
18
|
-
#define RJB_VERSION "1.2.
|
18
|
+
#define RJB_VERSION "1.2.6"
|
19
19
|
|
20
20
|
#include "ruby.h"
|
21
21
|
#include "extconf.h"
|
@@ -303,7 +303,7 @@ static VALUE jv2rv_r(JNIEnv* jenv, jvalue val)
|
|
303
303
|
return v;
|
304
304
|
}
|
305
305
|
|
306
|
-
|
306
|
+
VALUE jv2rv(JNIEnv* jenv, jvalue val)
|
307
307
|
{
|
308
308
|
if (RTEST(primitive_conversion))
|
309
309
|
{
|
data/ext/rjb.h
CHANGED
@@ -12,7 +12,7 @@
|
|
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.h
|
15
|
+
* $Id: rjb.h 126 2010-07-22 13:58:15Z arton $
|
16
16
|
* $Log: rjb.h,v $
|
17
17
|
* Revision 1.1 2005/01/16 17:36:10 arton
|
18
18
|
* Initial revision
|
@@ -73,6 +73,7 @@ extern jclass rjb_find_class(JNIEnv* jenv, VALUE name);
|
|
73
73
|
extern void rjb_release_string(JNIEnv *jenv, jstring str, const char* chrs);
|
74
74
|
extern VALUE rjb_load_vm_default();
|
75
75
|
extern VALUE rjb_safe_funcall(VALUE args);
|
76
|
+
extern VALUE jv2rv(JNIEnv* jenv, jvalue val);
|
76
77
|
|
77
78
|
/* in rjbexception.c */
|
78
79
|
extern VALUE rjb_get_exception_class(JNIEnv* jenv, jstring str);
|
data/ext/rjbexception.c
CHANGED
@@ -12,7 +12,7 @@
|
|
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: rjbexception.c
|
15
|
+
* $Id: rjbexception.c 126 2010-07-22 13:58:15Z arton $
|
16
16
|
*/
|
17
17
|
|
18
18
|
#include "ruby.h"
|
@@ -26,6 +26,12 @@
|
|
26
26
|
#include "riconv.h"
|
27
27
|
#include "rjb.h"
|
28
28
|
|
29
|
+
static VALUE missing_delegate(int argc, VALUE* argv, VALUE self)
|
30
|
+
{
|
31
|
+
ID rmid = rb_to_id(argv[0]);
|
32
|
+
return rb_funcall(rb_ivar_get(self, rb_intern("@cause")), rmid, argc - 1, argv + 1);
|
33
|
+
}
|
34
|
+
|
29
35
|
/*
|
30
36
|
* handle Java exception
|
31
37
|
* At this time, the Java exception is defined without the package name.
|
@@ -54,6 +60,7 @@ VALUE rjb_get_exception_class(JNIEnv* jenv, jstring str)
|
|
54
60
|
if (rexp == Qnil)
|
55
61
|
{
|
56
62
|
rexp = rb_define_class(pcls, rb_eStandardError);
|
63
|
+
rb_define_method(rexp, "method_missing", missing_delegate, -1);
|
57
64
|
#if defined(HAVE_RB_HASH_ASET) || defined(RUBINIUS)
|
58
65
|
rb_hash_aset(rjb_loaded_classes, cname, rexp);
|
59
66
|
#else
|
@@ -137,11 +144,16 @@ void rjb_check_exception(JNIEnv* jenv, int t)
|
|
137
144
|
}
|
138
145
|
if (rexp == Qnil)
|
139
146
|
{
|
147
|
+
(*jenv)->DeleteLocalRef(jenv, exp);
|
140
148
|
rb_raise(rb_eRuntimeError, "%s", msg);
|
141
149
|
}
|
142
150
|
else
|
143
151
|
{
|
144
|
-
|
152
|
+
VALUE rexpi = rb_funcall(rexp, rb_intern("new"), 1, rb_str_new2(msg));
|
153
|
+
jvalue val;
|
154
|
+
val.l = exp;
|
155
|
+
rb_ivar_set(rexpi, rb_intern("@cause"), jv2rv(jenv, val));
|
156
|
+
rb_exc_raise(rexpi);
|
145
157
|
}
|
146
158
|
}
|
147
159
|
}
|
data/test/test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/local/env ruby -Ku
|
2
2
|
# encoding: utf-8
|
3
|
-
# $Id: test.rb
|
3
|
+
# $Id: test.rb 126 2010-07-22 13:58:15Z arton $
|
4
4
|
|
5
5
|
begin
|
6
6
|
require 'rjb'
|
@@ -286,6 +286,7 @@ class TestRjb < Test::Unit::TestCase
|
|
286
286
|
@jInteger.parseInt('blabla')
|
287
287
|
flunk('no exception')
|
288
288
|
rescue NumberFormatException => e
|
289
|
+
assert_nil(e.cause)
|
289
290
|
# OK
|
290
291
|
end
|
291
292
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rjb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 6
|
10
|
+
version: 1.2.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- arton
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-07-22 00:00:00 +09:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|