Implementing a java interface with jruby

Hi,

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”
end

end

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.

Thanks!

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”
end
end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs