Forum: JRuby Implementing a java interface with jruby

4e78065963ce042cbab1d735ee480be0?d=identicon&s=25 Josh Hester (Guest)
on 2013-10-17 16:17
(Received via mailing list)

I'm trying to implement a very simple java interface in ruby.

On the java side I have:

package com.stuff;

public interface IProgressLiason {
 void voidMethod();

On the ruby side I have:

class ProgressLiason
  include com.stuff.IProgressLiason

  def voidMethod
    puts "foo"


Then I pass that implementation into a java method expecting an
IProgressLiason object, and get the following error:

expected [class com.stuff.IProgressLiason]; got:
[ProgressLiason_1368958158]; error: argument type mismatch

Can anyone see anything I may have missed?  It's as if ruby isn't
recognizing that this class is implementing an interface.

8ec3fe4f1729b3c07e3ea19421e6b646?d=identicon&s=25 Benjamin Ortega (Guest)
on 2013-10-17 17:36
(Received via mailing list)
I would do this using java_implements and java_signature in JRuby 1.7.4:

class ProgressLiason
  java_implements 'com.stuff.IProgressLiason'

  java_signature 'void voidMethod()'
  def voidMethod
    puts "foo"
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.