Cannot call super inside a method that overrides a protected method on Java
base class
--------------------------------------------------------------------------------------
Key: JRUBY-2861
URL: http://jira.codehaus.org/browse/JRUBY-2861
Project: JRuby
Issue Type: Bug
Components: Java Integration
Affects Versions: JRuby 1.1.3
Reporter: David Koontz
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
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email