[jruby-user] overloading Java methods via a module
Mike Luu <[email protected]>
| Newsgroups | gmane.comp.lang.jruby.user |
|---|---|
| Message-ID | <[email protected]> |
I can’t seem to overload a Java class instance method via a module.
```
require 'java'
module A
def getComment
'via module'
end
end
Java::JavaNet::HttpCookie.send(:include, A)
Java::JavaNet::HttpCookie.new('k', 'v').getComment
```
the last line returns the original java definition when I want it to return my overloaded version
What does work is opening up the class…
```
require 'java'
class Java::JavaNet::HttpCookie
def getComment
'via class opening'
end
end
java.net.HttpCookie.new('k', 'v').getComment
```
note: I’m using HttpCookie as an example :)
Thanks,
Mike
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email