I'm trying to implement a Java interface in a JRuby class, like this:
require 'java'
java_package 'net.jruby.test'
java_import "net.jruby.test.Service"
class RubyService
include Service
java_signature 'int sum(int, int)'
def sum(a,b)
a + b
end
end
The net.jruby.test.Service
interface is dead simple:
package net.jruby.test;
public interface Service
{
int sum(int a, int b);
}
After that I generate the .java class file with:
jrubyc --java ruby_service.rb
But the generated .java file (and consequently the .class file) do not implement the interface, look:
public class RubyService extends RubyObject {
Is there any way to achieve this?
Found the answer, instead of this:
include Service
I needed this:
java_implements 'Service'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With