I have a JRuby class that inherits from a java class (java.util.HashMap, for example). 3rd party java code is calling a reflective method like getDeclaredMethods()
on my class's java instance's getClass()
type. I need to push my method(s) defined in my ruby class (HM) into these "declared methods" before the it gets translated to java so they appear to the 3rd party java class. Anyone know a way? Here's my jruby code:
require 'java'
class HM < java.util.HashMap; end
hm = HM.new
puts hm.getClass()
# => org.jruby.proxy.java.util.HashMap$ProxyO
# a third party will make the following call:
puts hm.getClass().getDeclaredMethods().count
# => 2 methods
HM.class_eval do ; def value_at_key(key); return self[key]; end; end
puts hm.getClass().getDeclaredMethods().count
# => still 2 methods