Mike Luu
2014-07-17 22:54:57 UTC
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
```
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