Currently, protected methods do not show up as visible methods on a Ruby subclass. Calling super inside an overriden protected method will yield the error: super: no superclass method `fooMethod'
The workaround is two fold. First you must get a reference to the superclass' method, then instead of calling super in your overriden method you call the method reference you got earlier.
public BaseFoo {
protected void doFoo(String s) {
...
}
}
class Foo < Java::BaseFoo
def initialize
@do_foo_method = BaseFoo.java_class.declared_method("doFoo", java.lang.String)
@do_foo_method.accessible = true
end
def doFoo(s)
@do_foo_method.invoke(self.java_object, s.java_object)
#now you can do your method's logic here
end
end
1. You must call declared_method on the actual class the method is defined on. So if you have A < B, B < C and you're normally dealing with C but one of it's protected methods was actually declared on A you must use A.java_class.declared_method("someMethod", ... )
2. For primitive arguments use :int, :float, :boolean
FooClass.java_class.declared_method("primitiveMethod", :int, :int, :boolean)