rjb 1.6.9 → 1.7.1

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: db68bd4fe5b0ad8ab33ded261ddfbddac69c2f1713b3be5ccec7c19bf6d504ef
4
- data.tar.gz: 05cfef71f471a7e181964971cc9efdbf14a6be594957c8f7f2cc79d66abcb634
3
+ metadata.gz: 2f7c998ac143e7b5e4bbdc1aa2e74801684f2b3b9921a45bf121c5e5c59b9692
4
+ data.tar.gz: 137e9ee1214fcfadd9c797aff35877a19f3e2c8aa6be9d22ea1a2cdaac9ddfc5
5
5
  SHA512:
6
- metadata.gz: d03e67bbe85d5d21ad9368d9956d48e802d2948260f9df551ebf9c3ea5c98753400dfe0446bd0a6fa5711e1f23ce2ed3144e2529c88a6507d8d5ca01fbb91d79
7
- data.tar.gz: 1811c379afd0cfae646b3fd055399d706e3ee94270c9585f34b0ddbe4c7225694480fce0b390e9762e54292c1d6e8d9073a7deb71e6561b3923b46f79585109b
6
+ metadata.gz: 54efe3ce4191e7d64cadd2945dd6aec9445fbdb728f00ca6ae3c8f2ef82a5c256f7f452917b08528d06821ef6df906eea29bf152e886863b5ddf271291d903ce
7
+ data.tar.gz: ca5e74ae621c4531e188c10e3b502b07eb4f0ce3d1c9fb5abcff52390040bc999ad0429ca950e29694ee83c3a10bb0cc86a9bcecf2bb2420780ba73d7d4b36ea
data/ChangeLog CHANGED
@@ -1,9 +1,22 @@
1
+ Sun Apr 14 2024 arton
2
+ * ext/rjb.c
3
+ RJB_VERSION -> 1.7.1
4
+ * lib/rjb/extension.rb
5
+ skip $LOAD_PATH check if absolute path was given
6
+ * test/exttest.rb
7
+ add absolute path test
8
+ Sun Apr 14 2024 arton
9
+ * ext/rjb.c
10
+ RJB_VERSION -> 1.7.0
11
+ java2jniname replaces second '.' to '$' for nested/inner classes
12
+ * test/test.rb
13
+ add test_load_nested/inner_class_as_java_naming_convention
1
14
  Thu Nov 9 2023 arton
2
15
  * ext/rjb.c
3
16
  RJB_VERSION -> 1.6.9
4
17
  * ext/riconv.c
5
18
  fix CESU-8 check
6
- * test/est.rb
19
+ * test/test.rb
7
20
  add test_jav_hangul_syllable for checking CESU-8 bug (char start with 0xed)
8
21
  Thu Sep 28 2023 chaddow
9
22
  #93 fake allocation framework to remove T_DATA warning
data/README.md ADDED
@@ -0,0 +1,65 @@
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 your script.
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: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4733494
62
+ (Thanks Paul for this information).
63
+
64
+ # Contact
65
+ artonx@yahoo.co.jp
data/ext/extconf.h CHANGED
@@ -4,5 +4,5 @@
4
4
  #define HAVE_NL_LANGINFO 1
5
5
  #define HAVE_SETLOCALE 1
6
6
  #define HAVE_GETENV 1
7
- #define RJB_RUBY_VERSION_CODE 322
7
+ #define RJB_RUBY_VERSION_CODE 330
8
8
  #endif
data/ext/riconv.c CHANGED
@@ -195,7 +195,7 @@ static int contains_auxchar(const unsigned char* p)
195
195
  {
196
196
  while (*p)
197
197
  {
198
- if (*p == 0xed && *(p + 1) && *(p + 1))
198
+ if (*p == 0xed && *(p + 1) && *(p + 2))
199
199
  {
200
200
  #if defined(DEBUG)
201
201
  printf("find %02x %02x %02x %02x %02x %02x\n", *p, *(p + 1), *(p + 2), *(p + 3), *(p + 4), *(p + 5));
data/ext/rjb.c CHANGED
@@ -14,7 +14,7 @@
14
14
  *
15
15
  */
16
16
 
17
- #define RJB_VERSION "1.6.9"
17
+ #define RJB_VERSION "1.7.1"
18
18
 
19
19
  #include "ruby.h"
20
20
  #include "extconf.h"
@@ -185,11 +185,16 @@ void rjb_release_string(JNIEnv *jenv, jstring str, const char* chrs)
185
185
  static char* java2jniname(char* jnicls)
186
186
  {
187
187
  char* p;
188
+ int found_class_separator = isupper(*jnicls) ? 1 : 0;
188
189
  for (p = jnicls; *p; p++)
189
190
  {
190
191
  if (*p == '.')
191
192
  {
192
- *p = '/';
193
+ if (isupper(*(p + 1)))
194
+ {
195
+ found_class_separator++;
196
+ }
197
+ *p = (found_class_separator <= 1) ? '/' : '$';
193
198
  }
194
199
  }
195
200
  return jnicls;
data/lib/rjb/extension.rb CHANGED
@@ -51,7 +51,11 @@ module Kernel
51
51
 
52
52
  # This will maybe use the wrong jar file from a previous version of the GEM
53
53
  # puts "LOAD PATH #{$LOAD_PATH}"
54
- found_path = $LOAD_PATH.reverse.find{|p| File.exist?(File.join(p,path))}
54
+ if File.respond_to?(:absolute_path?) && File.absolute_path?(path)
55
+ found_path = File.exist?(path) ? '' : nil
56
+ else
57
+ found_path = $LOAD_PATH.reverse.find {|p| File.exist?(File.join(p, path))}
58
+ end
55
59
  raise unless found_path
56
60
 
57
61
  abs_path = File.join(found_path, path)
data/test/exttest.rb CHANGED
@@ -26,9 +26,18 @@ class ExtTestRjb < Test::Unit::TestCase
26
26
  def jp
27
27
  JavaPackage.new('jp')
28
28
  end
29
-
30
- def test_require_extension
29
+
30
+ def test_absolute_path_require
31
31
  assert !Rjb::loaded?
32
+ require File.absolute_path('./rjbtest.jar')
33
+ Rjb::load
34
+ assert Rjb::loaded?
35
+ base = jp.co.infoseek.hp.arton.rjb.Base.new
36
+ assert_equal('hello', base.instance_var)
37
+ end
38
+
39
+ def test_require_extension
40
+ org_load_path = $LOAD_PATH
32
41
  $LOAD_PATH << '.'
33
42
  require 'rjbtest.jar'
34
43
  Rjb::load
@@ -36,4 +45,5 @@ class ExtTestRjb < Test::Unit::TestCase
36
45
  base = jp.co.infoseek.hp.arton.rjb.Base.new
37
46
  assert_equal('hello', base.instance_var)
38
47
  end
48
+
39
49
  end
data/test/l.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'rjb'
2
+ require 'rjb/list'
3
+
4
+ ja = Rjb::import('java.util.ArrayList')
5
+ a = ja.new
6
+ a.add(1)
7
+ a.add(2)
8
+ a.add(3)
9
+ n = 1
10
+ a.each {|x|p x.intValue}
11
+ p n
data/test/test.rb CHANGED
@@ -986,4 +986,15 @@ class TestRjb < Test::Unit::TestCase
986
986
  assert_false e.respond_to? :unknown_method
987
987
  end
988
988
  end
989
+
990
+ def test_load_nested_class_as_java_convention
991
+ tstate = import('java.lang.Thread.State')
992
+ assert_equal(tstate.BLOCKED.ordinal, 2)
993
+ assert_equal(tstate.BLOCKED.name, 'BLOCKED')
994
+ end
995
+
996
+ def test_load_inner_class_as_java_convention
997
+ tes = import('java.util.HashMap.EntrySet')
998
+ assert_equal(tes._classname, 'java.lang.Class')
999
+ end
989
1000
  end
metadata CHANGED
@@ -1,19 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rjb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.9
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - arton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-09 00:00:00.000000000 Z
11
+ date: 2024-04-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: 'RJB is a bridge program that connect between Ruby and Java with Java
13
+ description: RJB is a Bridge library which connects Ruby and Java code using the Java
14
14
  Native Interface.
15
-
16
- '
17
15
  email: artonx@gmail.com
18
16
  executables: []
19
17
  extensions:
@@ -22,6 +20,7 @@ extra_rdoc_files: []
22
20
  files:
23
21
  - COPYING
24
22
  - ChangeLog
23
+ - README.md
25
24
  - data/rjb/jp/co/infoseek/hp/arton/rjb/RBridge.class
26
25
  - ext/RBridge.java
27
26
  - ext/depend.erb
@@ -61,6 +60,7 @@ files:
61
60
  - test/jp/co/infoseek/hp/arton/rjb/Test.class
62
61
  - test/jp/co/infoseek/hp/arton/rjb/Two.class
63
62
  - test/jp/co/infoseek/hp/arton/rjb/TwoCaller.class
63
+ - test/l.rb
64
64
  - test/listtest.rb
65
65
  - test/osx_jvmcheck.rb
66
66
  - test/rjbtest.jar
@@ -68,7 +68,7 @@ files:
68
68
  - test/test_osxjvm.rb
69
69
  - test/test_osxload.rb
70
70
  - test/test_unload.rb
71
- homepage: https://www.artonx.org/collabo/backyard/?RubyJavaBridge
71
+ homepage: http://www.artonx.org/collabo/backyard/?RubyJavaBridge
72
72
  licenses:
73
73
  - LGPL-2.1-or-later
74
74
  metadata: {}
@@ -87,11 +87,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  requirements:
90
- - none
91
90
  - JDK 5.0
92
- rubygems_version: 3.4.10
91
+ rubygems_version: 3.5.3
93
92
  signing_key:
94
93
  specification_version: 4
95
- summary: Ruby Java bridge
96
- test_files:
97
- - test/test.rb
94
+ summary: Ruby Java Bridge
95
+ test_files: []