Overriding static java methods in jruby

Hi all,

I have a java class like this:

public class A {
public static void method_a(String name) {
// some stuff
}

public static void method_b(String name) {
method_a(name);
}
}

I want to override this behaviour in ruby so I tried:

class B < A
def self.method_a(name)
# here I want to override what method_a does
end
end

B.method_b(“hello”)

I find method_a from the java class (A) gets called.
How can I get the behaviour I’m after?

Thanks
Mathijs

On Mon, Oct 12, 2009 at 5:54 AM, Mathijs K. [email protected]
wrote:

method_a(name);

B.method_b(“hello”)

I find method_a from the java class (A) gets called.
How can I get the behaviour I’m after?

The only option is to redefined method_b on the Ruby side as well.
JRuby is not able to modify existing Java classes that are already
compiled to invoke specific Java methods, so the change you made is
only visible to the Ruby side of things.

HTH,
/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

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