I am scripting Java using JRuby. By using JRebel, I can the automatically reload changed Java classes into the JRuby JVM without restarting. When I add a new Java method JRebel automatically reloads the class. My problem is that I cannot call this new method directly. Can I ask JRuby to refresh its method cache for the newly reloaded Java class? My only workaround is to call the new method reflectively using java_send.
Example:
step 1. Start irb session and java_import a Java class (say Person).
step 2. Add a getName method to Person and compile.
step 3. Create an instance of Person (p = Person.new). JRebel will show that it reloaded the java class.
step 4. Calling p.get_name results in a NoMethodError but p.java_send('getName') invokes the newly implemented getName method