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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2b0f2af57eaee97970ba6fc2edcf52b284e4b609f984e51be36affb6be3f185
4
- data.tar.gz: 76bbbcb0d8442a1c64ca5532f0b9678c2ed54537bc75a58e1b1ae3d996d07f6e
3
+ metadata.gz: 4a44bbac6e23b95fd5b2297053622034f4cc8027d656f546bce3d3d2e20646b4
4
+ data.tar.gz: 83ff490b4dd8fe79954832e355e4981e5dea72cf3dfbd8350698f869a7ca5eae
5
5
  SHA512:
6
- metadata.gz: 04f3b57c9041ee7862723ec31e86950b597611e334473c387b97a647478d6e170f099be3ab72fb3c8739950b4b49b1355d78922d426e04e73f7800e17949fb1c
7
- data.tar.gz: d3fa29ac0db4648212cef20077974a4167b217c7c7e044e928dae03570a2a456a1325561948d768bc3b52454cd73747db76f7387670deb766d59cb1c70913927
6
+ metadata.gz: 9e63eb18a2302be1b83db2e10486104dd5380cbcb7d623c2a2eb6a6203de21f750c03a26c7e6bbd6002adca588ca6d475a12368d72d5790fd6052738770c3ce8
7
+ data.tar.gz: 426214a2feae8412362efaabb2cf0c4a49882e5701d0dceb80cb91ea24dc686eebc6c9fdee81a216e692735a86d33c99bc72bf9efaae6b0d631e43f4fa9a4b27
data/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ Fri Dec 28 2018 arton
2
+ * ext/rjbexception.c
3
+ fix #60; stable java derived exception class for raise
4
+ * ext/rjb.c
5
+ RJB_VERSION -> 1.5.7
1
6
  Thu Dec 27 2018 sean-npu
2
7
  * ext/load.c
3
8
  support aarch64
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.6"
17
+ #define RJB_VERSION "1.5.7"
18
18
 
19
19
  #include "ruby.h"
20
20
  #include "extconf.h"
@@ -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
- return rb_funcall(rb_ivar_get(self, rb_intern("@cause")), rb_intern("cause"), 0);
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
- rexp = rb_define_class(pcls, rb_eStandardError);
74
- rb_define_method(rexp, "cause", get_cause, 0);
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
- st_insert(RHASH_TBL(rjb_loaded_classes), cname, rexp);
82
- #else
83
- st_insert(RHASH(rjb_loaded_classes)->tbl, cname, rexp);
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
- char* msg = "unknown exception";
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
+
@@ -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
@@ -0,0 +1,13 @@
1
+ class TestError < StandardError
2
+ end
3
+
4
+ begin
5
+ raise TestError.new
6
+ rescue => e
7
+ puts e.class
8
+ begin
9
+ raise e, 'abc'
10
+ rescue => f
11
+ puts f.class
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ begin
2
+ i.foo
3
+ rescue => e
4
+ puts e.class
5
+ begin
6
+ raise e
7
+ rescue => f
8
+ puts f.class
9
+ end
10
+ end
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.6
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