rjb 1.7.1 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ChangeLog +26 -0
- data/ext/extconf.rb +7 -2
- data/ext/load.c +16 -13
- data/ext/rjb.c +14 -10
- data/lib/rjb/extension.rb +1 -1
- data/lib/rjb.rb +14 -0
- data/test/jartest3.rb +2 -1
- data/test/jp/co/infoseek/hp/arton/rjb/Test105.class +0 -0
- data/test/test105.rb +28 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf18c1b6b1e6b35fcd568d56c8185e00c26041e1b84afbc97b36071523daab40
|
4
|
+
data.tar.gz: 7af7cbd1a3c6a8d7538bf3e0c06ed17e42ce01b3eb487a834612876bedadb837
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c37493cbabd35c53cf0ebf94e2cfbc961110e6d983b7c103893592a9dfe6381f1c0f4ad6abbb5af876edba47518fe63b90a7739e7c044d715450191682a9233a
|
7
|
+
data.tar.gz: bbcadae2f7ad325f451b8d909f4a0fb4723b264418052fda0a37b9ea0beb9b1108041e019855168085409ff03e81580b4dbe79b289a90a7d24f46c67528dc30f
|
data/ChangeLog
CHANGED
@@ -1,3 +1,29 @@
|
|
1
|
+
Wed May 1 2024 arton (reported and designed by uvlad7)
|
2
|
+
* test/Test105.java
|
3
|
+
add for test #105 (uvald7)
|
4
|
+
* test/test105.rb
|
5
|
+
add for test #105 (uvald7)
|
6
|
+
* ext/rjb.c
|
7
|
+
RJV_VERSION -> 1.7.3
|
8
|
+
invoke_by_instance takes six parameters. six is called by method_missing or _invoke
|
9
|
+
Wed May 1 2024 arton
|
10
|
+
* test/jartest3.rb
|
11
|
+
accept ClassNotFoundException for test
|
12
|
+
* ext/load.c
|
13
|
+
clear ruby error
|
14
|
+
* ext/rjb.c
|
15
|
+
change import => s_import for delegate. call Rjb::import instead of internal C fund.
|
16
|
+
* lib/rjb.rb
|
17
|
+
Rjb::import retry to import for NoSuchFieldException
|
18
|
+
Fri Apr 26 2024 arton
|
19
|
+
* ext/rjb.c
|
20
|
+
RJB_VERSION -> 1.7.2
|
21
|
+
* ext/extconf.rb
|
22
|
+
change javah and javac console encoding according to the locale (reported by winezer0)
|
23
|
+
* ext/load.c
|
24
|
+
fix win32 and cygwin JVM path detection (reported by winezer0)
|
25
|
+
* setup.rb
|
26
|
+
remove duplicate line
|
1
27
|
Sun Apr 14 2024 arton
|
2
28
|
* ext/rjb.c
|
3
29
|
RJB_VERSION -> 1.7.1
|
data/ext/extconf.rb
CHANGED
@@ -79,8 +79,13 @@ end
|
|
79
79
|
JAVAH_COMMAND = 'javac -h . -classpath ../data/rjb RBridge.java'.freeze
|
80
80
|
|
81
81
|
if find_executable('javah')
|
82
|
-
|
83
|
-
|
82
|
+
if defined?(Encoding) && ''.respond_to?(:force_encoding)
|
83
|
+
cversion = (`javac -version`.force_encoding(Encoding.locale_charmap).encode('utf-8') =~ /\d+\.\d+\.\d+/ ) ? $& : nil
|
84
|
+
hversion = (`javah -version`.force_encoding(Encoding.locale_charmap).encode('utf-8') =~ /\d+\.\d+\.\d+/ ) ? $& : nil
|
85
|
+
else
|
86
|
+
cversion = (`javac -version` =~ /\d+\.\d+\.\d+/ ) ? $& : nil
|
87
|
+
hversion = (`javah -version` =~ /\d+\.\d+\.\d+/ ) ? $& : nil
|
88
|
+
end
|
84
89
|
if cversion == hversion || cversion.nil?
|
85
90
|
javah = 'javah -classpath ../data/rjb jp.co.infoseek.hp.arton.rjb.RBridge'
|
86
91
|
else
|
data/ext/load.c
CHANGED
@@ -95,7 +95,6 @@
|
|
95
95
|
#define DIRSEPARATOR '/'
|
96
96
|
#define CLASSPATH_SEP ':'
|
97
97
|
#endif
|
98
|
-
|
99
98
|
#if defined(__APPLE__) && defined(__MACH__)
|
100
99
|
static char* CREATEJVM = "JNI_CreateJavaVM";
|
101
100
|
static char* GETDEFAULTJVMINITARGS = "JNI_GetDefaultJavaVMInitArgs";
|
@@ -107,7 +106,6 @@
|
|
107
106
|
typedef int (JNICALL *GETDEFAULTJAVAVMINITARGS)(void*);
|
108
107
|
typedef int (JNICALL *CREATEJAVAVM)(JavaVM**, JNIEnv**, void*);
|
109
108
|
|
110
|
-
|
111
109
|
static VALUE jvmdll = Qnil;
|
112
110
|
static VALUE getdefaultjavavminitargsfunc;
|
113
111
|
static VALUE createjavavmfunc;
|
@@ -147,13 +145,14 @@ static int open_jvm(char* libpath)
|
|
147
145
|
#if !defined(RUBINIUS)
|
148
146
|
if (state || !rb_const_defined_at(rb_cObject, rb_intern(DLNames[i])))
|
149
147
|
{
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
148
|
+
rb_set_errinfo(Qnil);
|
149
|
+
if (i > 0)
|
150
|
+
{
|
151
|
+
rb_raise(rb_eRuntimeError, "Constants DL or Fiddle is not defined.");
|
152
|
+
return 0;
|
153
|
+
}
|
154
|
+
}
|
155
|
+
else
|
157
156
|
#endif
|
158
157
|
{
|
159
158
|
sstat = 0;
|
@@ -167,9 +166,13 @@ static int open_jvm(char* libpath)
|
|
167
166
|
{
|
168
167
|
break;
|
169
168
|
}
|
170
|
-
else
|
171
|
-
|
172
|
-
|
169
|
+
else
|
170
|
+
{
|
171
|
+
rb_set_errinfo(Qnil);
|
172
|
+
if (i > 0)
|
173
|
+
{
|
174
|
+
return 0;
|
175
|
+
}
|
173
176
|
}
|
174
177
|
}
|
175
178
|
}
|
@@ -274,7 +277,7 @@ static int load_jvm(const char* jvmtype)
|
|
274
277
|
return 1;
|
275
278
|
}
|
276
279
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
277
|
-
|
280
|
+
sprintf(libpath, JVMDLL, java_home, jvmtype);
|
278
281
|
#else /* not Windows / MAC OS-X */
|
279
282
|
sprintf(libpath, JVMDLL, java_home, ARCH, jvmtype);
|
280
283
|
#endif
|
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,2018 arton
|
3
|
+
* Copyright(c) 2004,2005,2006,2007,2008,2009,2010,2011,2012,2014-2016,2018,2024 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.7.
|
17
|
+
#define RJB_VERSION "1.7.3"
|
18
18
|
|
19
19
|
#include "ruby.h"
|
20
20
|
#include "extconf.h"
|
@@ -93,6 +93,8 @@ static ID initialize_proxy;
|
|
93
93
|
static ID cvar_classpath;
|
94
94
|
static ID anonymousblock;
|
95
95
|
static ID id_call;
|
96
|
+
static ID id_import;
|
97
|
+
|
96
98
|
|
97
99
|
VALUE rjb_loaded_classes;
|
98
100
|
static VALUE proxies;
|
@@ -280,7 +282,7 @@ static VALUE jv2rclass(JNIEnv* jenv, jclass jc)
|
|
280
282
|
v = rb_hash_aref(rjb_loaded_classes, clsname);
|
281
283
|
if (v == Qnil)
|
282
284
|
{
|
283
|
-
|
285
|
+
v = rb_funcall(rjb, id_import, 1, clsname);
|
284
286
|
}
|
285
287
|
(*jenv)->DeleteLocalRef(jenv, jc);
|
286
288
|
return v;
|
@@ -321,7 +323,7 @@ static VALUE jv2rv_r(JNIEnv* jenv, jvalue val)
|
|
321
323
|
v = rb_hash_aref(rjb_loaded_classes, clsname);
|
322
324
|
if (v == Qnil)
|
323
325
|
{
|
324
|
-
|
326
|
+
v = rb_funcall(rjb, id_import, 1, clsname);
|
325
327
|
}
|
326
328
|
Data_Get_Struct(v, struct jv_data, ptr);
|
327
329
|
v = register_instance(jenv, v, (struct jv_data*)ptr, val.l);
|
@@ -3091,14 +3093,14 @@ static VALUE invoke(JNIEnv* jenv, struct cls_method* pm, struct jvi_data* ptr,
|
|
3091
3093
|
* Object invocation
|
3092
3094
|
*/
|
3093
3095
|
static VALUE invoke_by_instance(ID rmid, int argc, VALUE* argv,
|
3094
|
-
struct jvi_data* ptr, char* sig)
|
3096
|
+
struct jvi_data* ptr, char* sig, int called_by_invoke)
|
3095
3097
|
{
|
3096
3098
|
VALUE ret = Qnil;
|
3097
3099
|
JNIEnv* jenv = rjb_attach_current_thread();
|
3098
3100
|
struct cls_field* pf;
|
3099
3101
|
struct cls_method* pm;
|
3100
3102
|
const char* tname = rb_id2name(rmid);
|
3101
|
-
if (argc == 0 && st_lookup(ptr->fields, rmid, (st_data_t*)&pf))
|
3103
|
+
if (!called_by_invoke && argc == 0 && st_lookup(ptr->fields, rmid, (st_data_t*)&pf))
|
3102
3104
|
{
|
3103
3105
|
ret = getter(jenv, pf, ptr);
|
3104
3106
|
}
|
@@ -3155,7 +3157,7 @@ static VALUE rjb_i_invoke(int argc, VALUE* argv, VALUE self)
|
|
3155
3157
|
sig = NIL_P(vsig) ? NULL : StringValueCStr(vsig);
|
3156
3158
|
Data_Get_Struct(self, struct jvi_data, ptr);
|
3157
3159
|
|
3158
|
-
return invoke_by_instance(rmid, argc - 2, argv + 2, ptr, sig);
|
3160
|
+
return invoke_by_instance(rmid, argc - 2, argv + 2, ptr, sig, 1);
|
3159
3161
|
}
|
3160
3162
|
|
3161
3163
|
static VALUE rjb_i_missing(int argc, VALUE* argv, VALUE self)
|
@@ -3165,7 +3167,7 @@ static VALUE rjb_i_missing(int argc, VALUE* argv, VALUE self)
|
|
3165
3167
|
|
3166
3168
|
Data_Get_Struct(self, struct jvi_data, ptr);
|
3167
3169
|
|
3168
|
-
return invoke_by_instance(rmid, argc -1, argv + 1, ptr, NULL);
|
3170
|
+
return invoke_by_instance(rmid, argc -1, argv + 1, ptr, NULL, 0);
|
3169
3171
|
}
|
3170
3172
|
|
3171
3173
|
/*
|
@@ -3268,6 +3270,7 @@ static VALUE rjb_missing(int argc, VALUE* argv, VALUE self)
|
|
3268
3270
|
{
|
3269
3271
|
return r;
|
3270
3272
|
}
|
3273
|
+
rb_set_errinfo(Qnil);
|
3271
3274
|
}
|
3272
3275
|
|
3273
3276
|
Data_Get_Struct(self, struct jv_data, ptr);
|
@@ -3281,7 +3284,7 @@ static VALUE rjb_class_forname(int argc, VALUE* argv, VALUE self)
|
|
3281
3284
|
{
|
3282
3285
|
if (argc == 1)
|
3283
3286
|
{
|
3284
|
-
|
3287
|
+
return rjb_s_import(self, *argv);
|
3285
3288
|
}
|
3286
3289
|
else
|
3287
3290
|
{
|
@@ -3318,7 +3321,7 @@ void Init_rjbcore()
|
|
3318
3321
|
rb_define_module_function(rjb, "load", rjb_s_load, -1);
|
3319
3322
|
rb_define_module_function(rjb, "unload", rjb_s_unload, -1);
|
3320
3323
|
rb_define_module_function(rjb, "loaded?", rjb_s_loaded, 0);
|
3321
|
-
rb_define_module_function(rjb, "
|
3324
|
+
rb_define_module_function(rjb, "s_import", rjb_s_import, 1);
|
3322
3325
|
rb_define_module_function(rjb, "bind", rjb_s_bind, 2);
|
3323
3326
|
rb_define_module_function(rjb, "unbind", rjb_s_unbind, 1);
|
3324
3327
|
rb_define_module_function(rjb, "classes", rjb_s_classes, 0);
|
@@ -3363,6 +3366,7 @@ void Init_rjbcore()
|
|
3363
3366
|
rb_define_method(rjba, "method_missing", rjb_a_missing, -1);
|
3364
3367
|
anonymousblock = rb_intern("@anon_block");
|
3365
3368
|
id_call = rb_intern("call");
|
3369
|
+
id_import = rb_intern("import");
|
3366
3370
|
}
|
3367
3371
|
|
3368
3372
|
VALUE rjb_safe_funcall(VALUE args)
|
data/lib/rjb/extension.rb
CHANGED
data/lib/rjb.rb
CHANGED
@@ -66,6 +66,20 @@ end
|
|
66
66
|
require 'rjbcore'
|
67
67
|
|
68
68
|
module Rjb
|
69
|
+
def self.import(cls)
|
70
|
+
s_import(cls)
|
71
|
+
rescue NoSuchFieldError => e
|
72
|
+
puts "#{cls}: #{e.inspect}" if $VERBOSE
|
73
|
+
s_import(cls)
|
74
|
+
end
|
75
|
+
|
76
|
+
def import(cls)
|
77
|
+
s_import(cls)
|
78
|
+
rescue NoSuchFieldError => e
|
79
|
+
puts "#{cls}: #{e.inspect}" if $VERBOSE
|
80
|
+
s_import(cls)
|
81
|
+
end
|
82
|
+
|
69
83
|
module MODIFIER
|
70
84
|
def self.STATIC
|
71
85
|
8
|
data/test/jartest3.rb
CHANGED
@@ -21,7 +21,8 @@ class JarTest < Test::Unit::TestCase
|
|
21
21
|
begin
|
22
22
|
Rjb::import('jp.co.infoseek.hp.arton.rjb.JarTest2')
|
23
23
|
fail 'no exception'
|
24
|
-
rescue
|
24
|
+
rescue => e
|
25
|
+
['NoClassDefFoundError', 'ClassNotFoundException'].any? {|nm| e.class == nm}
|
25
26
|
assert true
|
26
27
|
end
|
27
28
|
end
|
Binary file
|
data/test/test105.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
begin
|
2
|
+
require 'rjb'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems'
|
5
|
+
require 'rjb'
|
6
|
+
end
|
7
|
+
require 'test/unit'
|
8
|
+
|
9
|
+
class Test105 < Test::Unit::TestCase
|
10
|
+
include Rjb
|
11
|
+
def setup
|
12
|
+
Rjb::load('.')
|
13
|
+
@test105 = import('jp.co.infoseek.hp.arton.rjb.Test105')
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_field
|
17
|
+
test = @test105.new('xyz')
|
18
|
+
assert_equal('xyz', test.test)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_method
|
22
|
+
test = @test105.new('xyz')
|
23
|
+
ret = test._invoke('test')
|
24
|
+
assert_equal('method_xyz', ret)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rjb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- arton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: RJB is a Bridge library which connects Ruby and Java code using the Java
|
14
14
|
Native Interface.
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- test/jp/co/infoseek/hp/arton/rjb/JarTest2.class
|
59
59
|
- test/jp/co/infoseek/hp/arton/rjb/Test$TestTypes.class
|
60
60
|
- test/jp/co/infoseek/hp/arton/rjb/Test.class
|
61
|
+
- test/jp/co/infoseek/hp/arton/rjb/Test105.class
|
61
62
|
- test/jp/co/infoseek/hp/arton/rjb/Two.class
|
62
63
|
- test/jp/co/infoseek/hp/arton/rjb/TwoCaller.class
|
63
64
|
- test/l.rb
|
@@ -65,6 +66,7 @@ files:
|
|
65
66
|
- test/osx_jvmcheck.rb
|
66
67
|
- test/rjbtest.jar
|
67
68
|
- test/test.rb
|
69
|
+
- test/test105.rb
|
68
70
|
- test/test_osxjvm.rb
|
69
71
|
- test/test_osxload.rb
|
70
72
|
- test/test_unload.rb
|