rjb 1.6.9 → 1.7.0

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: eb30d6521841ff5187f03891746f241d1484f6acec69219124321a77d0f9e183
4
+ data.tar.gz: fcbcc52de14fd2103fdb2e3ffad9644cbf74587c621c5362c02a4fa46c6a40b2
5
5
  SHA512:
6
- metadata.gz: d03e67bbe85d5d21ad9368d9956d48e802d2948260f9df551ebf9c3ea5c98753400dfe0446bd0a6fa5711e1f23ce2ed3144e2529c88a6507d8d5ca01fbb91d79
7
- data.tar.gz: 1811c379afd0cfae646b3fd055399d706e3ee94270c9585f34b0ddbe4c7225694480fce0b390e9762e54292c1d6e8d9073a7deb71e6561b3923b46f79585109b
6
+ metadata.gz: 77f20a728bad840480a3851c78a60970cd6e773d3b4261c8d738099177af9f69d04010d7ba3c4ee914dcbed0c5608976689ba4a7cd7d94797d523709ab1b81ad
7
+ data.tar.gz: 499ca077eb5cedae7eef353d2964a7e6be942bcbddcf14939d141913856ede4a2d5f09cbf76a0edebb4cb00c021ba64859dc1517dc9769a85ea609b46ec9b249
data/ChangeLog CHANGED
@@ -1,9 +1,15 @@
1
+ Sun Apr 14 2024 arton
2
+ * ext/rjb.c
3
+ RJB_VERSION -> 1.7.0
4
+ java2jniname replaces second '.' to '$' for nested/inner classes
5
+ * test/test.rb
6
+ add test_load_nested/inner_class_as_java_naming_convention
1
7
  Thu Nov 9 2023 arton
2
8
  * ext/rjb.c
3
9
  RJB_VERSION -> 1.6.9
4
10
  * ext/riconv.c
5
11
  fix CESU-8 check
6
- * test/est.rb
12
+ * test/test.rb
7
13
  add test_jav_hangul_syllable for checking CESU-8 bug (char start with 0xed)
8
14
  Thu Sep 28 2023 chaddow
9
15
  #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.0"
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/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/listtest.rb CHANGED
@@ -4,20 +4,22 @@
4
4
  Copyright(c) 2012 arton
5
5
  =end
6
6
 
7
+ require 'test/unit'
7
8
  begin
8
9
  require 'rjb/list'
9
10
  rescue LoadError
10
11
  require 'rubygems'
11
12
  require 'rjb/list'
12
13
  end
13
- require 'test/unit'
14
14
  require 'fileutils'
15
15
 
16
16
  class ListTest < Test::Unit::TestCase
17
17
  include Rjb
18
18
  def test_create
19
19
  ja = import('java.util.ArrayList')
20
+ p 'imported'
20
21
  a = ja.new
22
+ p 'new'
21
23
  a.add(1)
22
24
  a.add(2)
23
25
  a.add(3)
@@ -28,6 +30,7 @@ class ListTest < Test::Unit::TestCase
28
30
  end
29
31
  assert_equal 4, n
30
32
  end
33
+ =begin
31
34
  def test_returned_proxy
32
35
  ja = import('java.util.Arrays')
33
36
  a = ja.as_list([1, 2, 3])
@@ -52,5 +55,6 @@ class ListTest < Test::Unit::TestCase
52
55
  ja = import('java.util.Arrays')
53
56
  assert_equal 55, ja.as_list((1..10).to_a).inject(0) {|r, e| r + e.intValue}
54
57
  end
58
+ =end
55
59
  end
56
60
 
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.0
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: []