arton / rjb

Ruby Java Bridge
https://www.artonx.org/collabo/backyard/?RubyJavaBridge
GNU Lesser General Public License v2.1
117 stars 34 forks source link

How to specify signature? #110

Closed uvlad7 closed 3 weeks ago

uvlad7 commented 3 months ago

I need to call initialize(Ljava/util/List;)Lorg/jruby/Ruby; static method, how can I specify that Ljava/util/List; part? Does it work the same for instance methods?

(It actually works like that

JavaEmbedUtils._invoke('initialize', nil, ArrayList.new)

I'm just curious.)

arton commented 3 months ago

@uvlad7 I think you don't need to call with signature parameter. I believe you can call the method as

JavaEmbedUtils.initialize(ArrayList.new())

Because Rjb checks the method signature with given parameters. You should use _invoke when you call such as Foo#bar(short x) or Foo#bar(long x) because Rjb and Ruby can't judge given number was short or long.