I understood how to do it. Rather than:
IRubyObject io = adapter.eval(runtime, <scriptContent>);
I have to do:
JavaEmbedUtils.EvalUnit evalUnit = adapter.parse(runtime, <scriptContent>, <file name>, 1); IRubyObject io = evalUnit.run();