rjb 1.3.5 → 1.3.6

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,11 @@
1
+ Wed Nov 09 arton
2
+ *ext/rjb.c
3
+ RJB_VERSION -> 1.3.6
4
+ *ext/rjbexception.c
5
+ add to_str method into the exception class.
6
+ ruby internally calls the method when reraising the exception.
7
+ *test/test.rb (test_reraise_exception)
8
+ add reraise test
1
9
  Mon Jul 18 arton
2
10
  *ext/rjb.c
3
11
  fix inhiritance test.
data/ext/load.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: load.c 159 2010-11-16 16:35:49Z arton $
15
+ * $Id: load.c 167 2011-07-15 17:40:25Z arton $
16
16
  */
17
17
 
18
18
  #include <stdlib.h>
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 170 2011-07-18 12:45:13Z arton $
15
+ * $Id: rjb.c 173 2011-11-09 13:46:04Z arton $
16
16
  */
17
17
 
18
- #define RJB_VERSION "1.3.5"
18
+ #define RJB_VERSION "1.3.6"
19
19
 
20
20
  #include "ruby.h"
21
21
  #include "extconf.h"
@@ -131,6 +131,7 @@ static jmethodID get_system_classloader;
131
131
  static jclass j_url_loader;
132
132
  static jobject url_loader;
133
133
  static jmethodID url_loader_new;
134
+ static jmethodID url_geturls;
134
135
  /* URL global reference */
135
136
  static jclass j_url;
136
137
  static jmethodID url_new;
@@ -2551,6 +2552,8 @@ static VALUE rjb_s_add_jar(VALUE self, VALUE jarname)
2551
2552
  "(Ljava/lang/String;)Ljava/lang/Class;");
2552
2553
  RJB_LOAD_METHOD(url_loader_new, j_url_loader, "<init>",
2553
2554
  "([Ljava/net/URL;Ljava/lang/ClassLoader;)V");
2555
+ RJB_LOAD_METHOD(url_geturls, j_url_loader, "getURLs",
2556
+ "()[Ljava/net/URL;");
2554
2557
  }
2555
2558
  args[0].l = (*jenv)->NewObjectArray(jenv, (count == 0) ? 1 : count, j_url, NULL);
2556
2559
  rjb_check_exception(jenv, 0);
@@ -2575,6 +2578,17 @@ static VALUE rjb_s_add_jar(VALUE self, VALUE jarname)
2575
2578
  return Qtrue;
2576
2579
  }
2577
2580
 
2581
+ static VALUE rjb_s_urls(VALUE self)
2582
+ {
2583
+ JNIEnv* jenv;
2584
+ jvalue ret;
2585
+ if (!url_loader) return Qnil;
2586
+ jenv = rjb_prelude();
2587
+ ret.l = (*jenv)->CallObjectMethod(jenv, url_loader, url_geturls);
2588
+ return jarray2rv(jenv, ret);
2589
+ }
2590
+
2591
+
2578
2592
  /*
2579
2593
  * return class name
2580
2594
  */
@@ -3155,6 +3169,7 @@ void Init_rjbcore()
3155
3169
  rb_define_module_function(rjb, "add_classpath", rjb_s_add_classpath, 1);
3156
3170
  rb_define_module_function(rjb, "add_jar", rjb_s_add_jar, 1);
3157
3171
  rb_define_alias(rjb, "add_jars", "add_jar");
3172
+ rb_define_module_function(rjb, "urls", rjb_s_urls, 0);
3158
3173
  rb_define_const(rjb, "VERSION", rb_str_new2(RJB_VERSION));
3159
3174
  rb_define_class_variable(rjb, "@@classpath", rb_ary_new());
3160
3175
  cvar_classpath = rb_intern("@@classpath");
@@ -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 126 2010-07-22 13:58:15Z arton $
15
+ * $Id: rjbexception.c 174 2011-11-09 13:47:43Z arton $
16
16
  */
17
17
 
18
18
  #include "ruby.h"
@@ -32,6 +32,12 @@ static VALUE missing_delegate(int argc, VALUE* argv, VALUE self)
32
32
  return rb_funcall(rb_ivar_get(self, rb_intern("@cause")), rmid, argc - 1, argv + 1);
33
33
  }
34
34
 
35
+ static VALUE exception_to_s(VALUE self)
36
+ {
37
+ return rb_funcall(rb_ivar_get(self, rb_intern("@cause")),
38
+ rb_intern("toString"), 0);
39
+ }
40
+
35
41
  /*
36
42
  * handle Java exception
37
43
  * At this time, the Java exception is defined without the package name.
@@ -61,6 +67,7 @@ VALUE rjb_get_exception_class(JNIEnv* jenv, jstring str)
61
67
  {
62
68
  rexp = rb_define_class(pcls, rb_eStandardError);
63
69
  rb_define_method(rexp, "method_missing", missing_delegate, -1);
70
+ rb_define_method(rexp, "to_str", exception_to_s, 0);
64
71
  #if defined(HAVE_RB_HASH_ASET) || defined(RUBINIUS)
65
72
  rb_hash_aset(rjb_loaded_classes, cname, rexp);
66
73
  #else
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
- -- Notice for opening non-ASCII 7bit filename
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
File without changes
@@ -1,6 +1,6 @@
1
1
  #!/usr/local/env ruby -Ku
2
2
  # encoding: utf-8
3
- # $Id: test.rb 170 2011-07-18 12:45:13Z arton $
3
+ # $Id: test.rb 174 2011-11-09 13:47:43Z arton $
4
4
 
5
5
  begin
6
6
  require 'rjb'
@@ -792,5 +792,22 @@ class TestRjb < Test::Unit::TestCase
792
792
  assert_equal 'method1', ret[0]
793
793
  assert_equal 'method2', ret[1]
794
794
  end
795
+
796
+ def cause_exception
797
+ begin
798
+ @jInteger.parseInt('blabla')
799
+ rescue NumberFormatException => e
800
+ raise
801
+ end
802
+ end
803
+
804
+ def test_reraise_exception()
805
+ begin
806
+ cause_exception
807
+ rescue
808
+ assert($!.to_s =~ /NumberFormatException/)
809
+ end
810
+ end
811
+
795
812
  end
796
813
 
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rjb
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 3
8
- - 5
9
- version: 1.3.5
4
+ prerelease:
5
+ version: 1.3.6
10
6
  platform: ruby
11
7
  authors:
12
8
  - arton
@@ -14,8 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-07-18 00:00:00 +09:00
18
- default_executable:
13
+ date: 2011-11-09 00:00:00 Z
19
14
  dependencies: []
20
15
 
21
16
  description: |
@@ -36,7 +31,6 @@ files:
36
31
  - ext/rjb.c
37
32
  - ext/jp_co_infoseek_hp_arton_rjb_RBridge.h
38
33
  - ext/riconv.h
39
- - ext/extconf.h
40
34
  - ext/jniwrap.h
41
35
  - ext/rjb.h
42
36
  - ext/depend
@@ -63,7 +57,6 @@ files:
63
57
  - readme.sj
64
58
  - readme.txt
65
59
  - ext/extconf.rb
66
- has_rdoc: true
67
60
  homepage: http://rjb.rubyforge.org/
68
61
  licenses: []
69
62
 
@@ -77,24 +70,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
70
  requirements:
78
71
  - - ">="
79
72
  - !ruby/object:Gem::Version
80
- segments:
81
- - 1
82
- - 8
83
- - 2
84
73
  version: 1.8.2
85
74
  required_rubygems_version: !ruby/object:Gem::Requirement
86
75
  none: false
87
76
  requirements:
88
77
  - - ">="
89
78
  - !ruby/object:Gem::Version
90
- segments:
91
- - 0
92
79
  version: "0"
93
80
  requirements:
94
81
  - none
95
82
  - JDK 5.0
96
83
  rubyforge_project: rjb
97
- rubygems_version: 1.3.7
84
+ rubygems_version: 1.8.11
98
85
  signing_key:
99
86
  specification_version: 3
100
87
  summary: Ruby Java bridge
@@ -1,8 +0,0 @@
1
- #ifndef EXTCONF_H
2
- #define EXTCONF_H
3
- #define HAVE_JNI_H 1
4
- #define HAVE_DL_H 1
5
- #define HAVE_SETLOCALE 1
6
- #define HAVE_GETENV 1
7
- #define RJB_RUBY_VERSION_CODE 187
8
- #endif