Ruby.evalScriptlet: scope of local variables in JSE / OSGi


#1

Is the scope of a local variable supposed to span multiple calls to
Ruby.evalScriptlet? Are there any differences between running it in
plain Java and running it within an OSGi bundle? Given the following
code fragment:

Ruby runtime = JavaEmbedUtils.initialize(Collections.EMPTY_LIST);
try {
  runtime.evalScriptlet("a = 15; ");
  runtime.evalScriptlet("puts \"result: #{a}\"");
} catch (Exception e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
}

I’m getting the expected

result: 15

when running as a “normal” java application. When I try the same code in
an OSGi bundle, I’m getting

osgi> :1: undefined local variable or method `a’ for main:Object
(NameError)
…internal jruby stack elided…
from (unknown).(unknown)(:1)

Is that to be expected?

Any help/hints welcome.

best regards

Jerry