title: Can I run JRuby code from one JVM in another JVM?
body: <p>An interesting idea came in which I would rather like to do but can't figure out whether it would be possible or not (guessing that it's closer to not, though.)</p>
  
  <p>A script wants to do something like this:</p>
  
  <pre><code>process_recursively(top_item) do |item|
    if item.text =~ /evil/
      item.add_tag(evil)
    end
  end
  </code></pre>
  
  <p>Conceptually, this would work like so:</p>
  
  <pre><code>def process_recursively(item, &amp;block)
    block.call(item)
    item.children.each { |child| process_recursively(child) }
  end
  </code></pre>
  
  <p>But the catch is, the real system (which is implemented in Java, not Ruby) actually makes the call to process the item from a different JVM, so that a JVM crashing doesn't destroy the entire processing run.</p>
  
  <p>I know this sort of thing was possible in an awkward way with RMI back when that was still popular, but is there some way to make this crazy idea work for something like JRuby?</p>
  
  <p>Ideally, I would like to have it work for any JSR223 scripting language, but I'm not holding my breath on that.</p>