Java method overloading

I read in a message thread from September 2008 this:
“Any methods defined on the Ruby-side for a Java class won’t be seen
on the Java side.”

Is this still true now?

Im working in JRuby with the MongoDb java driver

In the MongoDb java driver jar the org.bson.BasicBSONCallback class
has the following method…

public void gotSymbol( String name , String v ){
    _put( name , v );
}

I need it to be…

public void gotSymbol( String name , String v ){
    cur().put( name , new Symbol(v) );
}

This is so the driver, when decoding the bson object from mongo will
not decode a field stored as a Symbol BSON type to a Java string.

Can this be done somehow?

Thanks Guy

if you override the method in ruby land and “only call it from ruby
land” then it will call your overridden method.

If you need to override a method in “java land” then you’ll need to
subclass the class I guess and override it there, and just use your
subclass.
HTH.
-r

On Tue, Oct 4, 2011 at 9:40 PM, Roger P. [email protected] wrote:

Posted via http://www.ruby-forum.com/.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Thanks for that. Unfortunately the method in question is used deep
down in the Java driver. I have compiled my change into a custom jar
which will ship with my gem. I have raised a Jira enhancement
request. I will have to live with a custom jar for now.

G

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs