rjb 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/ext/rjb.c +11 -2
  2. data/test/test.rb +10 -0
  3. metadata +6 -6
data/ext/rjb.c CHANGED
@@ -15,7 +15,7 @@
15
15
  * $Id: rjb.c 8 2006-11-20 19:17:22Z arton $
16
16
  */
17
17
 
18
- #define RJB_VERSION "1.0.3"
18
+ #define RJB_VERSION "1.0.4"
19
19
 
20
20
  #include "ruby.h"
21
21
  #include "st.h"
@@ -1885,6 +1885,7 @@ static VALUE rjb_newinstance_s(int argc, VALUE* argv, VALUE self)
1885
1885
  VALUE ret = Qnil;
1886
1886
  struct jv_data* ptr;
1887
1887
  JNIEnv* jenv = rjb_attach_current_thread();
1888
+ int found = 0;
1888
1889
 
1889
1890
  rb_scan_args(argc, argv, "1*", &vsig, &rest);
1890
1891
  sig = StringValueCStr(vsig);
@@ -1897,11 +1898,15 @@ static VALUE rjb_newinstance_s(int argc, VALUE* argv, VALUE self)
1897
1898
  if ((*pc)->arg_count == argc - 1
1898
1899
  && !strcmp(sig, (*pc)->method_signature))
1899
1900
  {
1901
+ found = 1;
1900
1902
  ret = createinstance(jenv, argc - 1, argv + 1, &ptr->idata, *pc);
1901
1903
  break;
1902
1904
  }
1903
1905
  }
1904
1906
  }
1907
+ if (!found) {
1908
+ rb_raise(rb_eRuntimeError, "Constructor not found");
1909
+ }
1905
1910
  return ret;
1906
1911
  }
1907
1912
 
@@ -1911,12 +1916,13 @@ static VALUE rjb_newinstance(int argc, VALUE* argv, VALUE self)
1911
1916
  struct jv_data* ptr;
1912
1917
  struct cls_constructor** pc;
1913
1918
  JNIEnv* jenv = rjb_attach_current_thread();
1919
+ int found = 0;
1914
1920
 
1915
1921
  Data_Get_Struct(self, struct jv_data, ptr);
1916
1922
 
1917
1923
  if (ptr->constructors)
1918
1924
  {
1919
- int i, found = 0;
1925
+ int i;
1920
1926
  char* psig;
1921
1927
  for (pc = ptr->constructors; *pc; pc++)
1922
1928
  {
@@ -1941,6 +1947,9 @@ static VALUE rjb_newinstance(int argc, VALUE* argv, VALUE self)
1941
1947
  }
1942
1948
  }
1943
1949
  }
1950
+ if (!found) {
1951
+ rb_raise(rb_eRuntimeError, "Constructor not found");
1952
+ }
1944
1953
  return ret;
1945
1954
  }
1946
1955
 
data/test/test.rb CHANGED
@@ -411,5 +411,15 @@ class TestRjb < Test::Unit::TestCase
411
411
  assert_equal(nil, test.callWithArraies(nil, nil, nil, nil, nil, nil,
412
412
  nil, nil))
413
413
  end
414
+
415
+ def test_failed_constructor_call()
416
+ test = import('java.lang.String')
417
+ begin
418
+ s = test.new('a', 'b', 'c')
419
+ flunk('no exception')
420
+ rescue RuntimeError => e
421
+ assert(e)
422
+ end
423
+ end
414
424
  end
415
425
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: rjb
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.3
7
- date: 2006-11-21 00:00:00 +09:00
6
+ version: 1.0.4
7
+ date: 2007-05-06 00:00:00 +09:00
8
8
  summary: Ruby Java bridge
9
9
  require_paths:
10
10
  - lib
@@ -30,20 +30,20 @@ authors:
30
30
  - arton
31
31
  files:
32
32
  - ext/RBridge.java
33
+ - ext/load.c
33
34
  - ext/riconv.c
34
- - ext/rjb.c
35
35
  - ext/rjbexception.c
36
- - ext/load.c
36
+ - ext/rjb.c
37
37
  - ext/jniwrap.h
38
+ - ext/rjb.h
38
39
  - ext/riconv.h
39
40
  - ext/jp_co_infoseek_hp_arton_rjb_RBridge.h
40
- - ext/rjb.h
41
41
  - ext/depend
42
42
  - data/rjb/jp/co/infoseek/hp/arton/rjb/RBridge.class
43
43
  - lib/rjb.rb
44
44
  - samples/filechooser.rb
45
- - test/test.rb
46
45
  - test/gctest.rb
46
+ - test/test.rb
47
47
  - test/jp/co/infoseek/hp/arton/rjb/ExtBase.class
48
48
  - test/jp/co/infoseek/hp/arton/rjb/Test.class
49
49
  - test/jp/co/infoseek/hp/arton/rjb/IBase.class