rjb 1.5.6 → 1.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +5 -0
- data/ext/rjb.c +2 -2
- data/ext/rjbexception.c +9 -23
- 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/x.rb +10 -0
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a44bbac6e23b95fd5b2297053622034f4cc8027d656f546bce3d3d2e20646b4
|
4
|
+
data.tar.gz: 83ff490b4dd8fe79954832e355e4981e5dea72cf3dfbd8350698f869a7ca5eae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e63eb18a2302be1b83db2e10486104dd5380cbcb7d623c2a2eb6a6203de21f750c03a26c7e6bbd6002adca588ca6d475a12368d72d5790fd6052738770c3ce8
|
7
|
+
data.tar.gz: 426214a2feae8412362efaabb2cf0c4a49882e5701d0dceb80cb91ea24dc686eebc6c9fdee81a216e692735a86d33c99bc72bf9efaae6b0d631e43f4fa9a4b27
|
data/ChangeLog
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.7"
|
18
18
|
|
19
19
|
#include "ruby.h"
|
20
20
|
#include "extconf.h"
|
data/ext/rjbexception.c
CHANGED
@@ -26,21 +26,9 @@
|
|
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
|
-
|
35
29
|
static VALUE get_cause(VALUE self)
|
36
30
|
{
|
37
|
-
|
38
|
-
}
|
39
|
-
|
40
|
-
static VALUE exception_to_s(VALUE self)
|
41
|
-
{
|
42
|
-
return rb_funcall(rb_ivar_get(self, rb_intern("@cause")),
|
43
|
-
rb_intern("toString"), 0);
|
31
|
+
return rb_funcall(rb_ivar_get(self, rb_intern("@cause")), rb_intern("cause"), 0);
|
44
32
|
}
|
45
33
|
|
46
34
|
/*
|
@@ -70,18 +58,16 @@ VALUE rjb_get_exception_class(JNIEnv* jenv, jstring str)
|
|
70
58
|
rexp = rb_hash_aref(rjb_loaded_classes, cname);
|
71
59
|
if (rexp == Qnil)
|
72
60
|
{
|
73
|
-
|
74
|
-
|
75
|
-
rb_define_method(rexp, "method_missing", missing_delegate, -1);
|
76
|
-
rb_define_method(rexp, "to_str", exception_to_s, 0);
|
61
|
+
rexp = rb_define_class(pcls, rb_eStandardError);
|
62
|
+
rb_define_method(rexp, "cause", get_cause, 0);
|
77
63
|
#if defined(HAVE_RB_HASH_ASET) || defined(RUBINIUS)
|
78
64
|
rb_hash_aset(rjb_loaded_classes, cname, rexp);
|
79
65
|
#else
|
80
|
-
#ifdef RHASH_TBL
|
81
|
-
|
82
|
-
#else
|
83
|
-
|
84
|
-
#endif
|
66
|
+
#ifdef RHASH_TBL
|
67
|
+
st_insert(RHASH_TBL(rjb_loaded_classes), cname, rexp);
|
68
|
+
#else
|
69
|
+
st_insert(RHASH(rjb_loaded_classes)->tbl, cname, rexp);
|
70
|
+
#endif
|
85
71
|
#endif
|
86
72
|
|
87
73
|
}
|
@@ -140,7 +126,7 @@ void rjb_check_exception(JNIEnv* jenv, int t)
|
|
140
126
|
(*jenv)->ExceptionClear(jenv);
|
141
127
|
if(1)
|
142
128
|
{
|
143
|
-
|
129
|
+
char* msg = (char*)"unknown exception";
|
144
130
|
jclass cls = (*jenv)->GetObjectClass(jenv, exp);
|
145
131
|
jstring str = (*jenv)->CallObjectMethod(jenv, exp, rjb_throwable_getMessage);
|
146
132
|
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/x.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- arton
|
@@ -44,6 +44,10 @@ files:
|
|
44
44
|
- readme.txt
|
45
45
|
- samples/filechooser.rb
|
46
46
|
- samples/unzip.rb
|
47
|
+
- test/anon-test-50.rb
|
48
|
+
- test/anon-test-60.rb
|
49
|
+
- test/anon.rb
|
50
|
+
- test/b.rb
|
47
51
|
- test/exttest.rb
|
48
52
|
- test/gctest.rb
|
49
53
|
- test/jartest.jar
|
@@ -67,6 +71,7 @@ files:
|
|
67
71
|
- test/test_osxjvm.rb
|
68
72
|
- test/test_osxload.rb
|
69
73
|
- test/test_unload.rb
|
74
|
+
- test/x.rb
|
70
75
|
homepage: https://www.artonx.org/collabo/backyard/?RubyJavaBridge
|
71
76
|
licenses:
|
72
77
|
- LGPL
|