Fwd: JRuby 1.4.0RC1 - changes to embedding?

In the RC1 release thread, Thomas E Enebo [email protected] wrote:

Bug reports welcome and requested!

Please try your apps against 1.4.0RC1 ASAP and report problems

Not sure if these count, but thought I would mention them anyway. We’re
using JRuby in an embedded context and two sanity check tests fail for
us
when switching from jruby-engine to JRuby’s new built-in support for
javax.script.

  1. This one might be a bug, although the impact is low.

    public void testWriterEncoding() throws Exception {
    String testString = “\u30C6\u30B9\u30C8”;
    assumeThat(Charset.defaultCharset(), canEncode(testString));

     ScriptEngineManager manager = new ScriptEngineManager();
     ScriptEngine engine = manager.getEngineByExtension("rb");
    
     ScriptContext context = new SimpleScriptContext();
     StringWriter stringWriter = new StringWriter();
     context.setWriter(stringWriter);
    
     engine.eval("puts '" + testString + '\'', context);
     assertEquals("Wrong value came out on the Writer",
    

testString, stringWriter.toString().trim());
}

The test itself passes but we get a mystifying warning on stderr:

:1 warning: already initialized constant STDERR

As you can see, the script is a single line of code and it certainly
isn’t
trying to define a constant, so I have to imagine every script gets this
warning.

  1. This one is not a bug but the behaviour changed for some reason:

    public void testErrorBehaviourForUnknownSymbol() throws Exception {
    ScriptEngineManager manager = new ScriptEngineManager();
    ScriptEngine engine = manager.getEngineByExtension(“rb”);

     try {
         engine.eval("no_method_with_this_name");
         fail("Expected ScriptException");
     } catch (ScriptException e) {
         RaiseException cause = (RaiseException) e.getCause();
         cause.toString();
         StringWriter writer = new StringWriter();
         cause.printStackTrace(new PrintWriter(writer));
         assertTrue("Not seeing the expected string at the
    

start", writer.toString().startsWith(“undefined local variable or
method”));
}
}

This fails because e.getCause() is now a RuntimeException. The
RaiseException we expected is now inside the RuntimeException but it’s
still
present, so if there is a good reason why this additional level of
exceptions was added, I’ll just change our test. As RaiseException is
already a RuntimeException I’m finding it hard to explain why it needed
to
be changed. :slight_smile:

TX

On Tue, Oct 6, 2009 at 7:26 PM, Trejkaz [email protected] wrote:

In the RC1 release thread, Thomas E Enebo [email protected] wrote:

Bug reports welcome and requested!

Please try your apps against 1.4.0RC1 ASAP and report problems

Not sure if these count, but thought I would mention them anyway. We’re
using JRuby in an embedded context and two sanity check tests fail for us
when switching from jruby-engine to JRuby’s new built-in support for
javax.script.

I think here is a good place to report or discuss about embedding API,
too, since many people see problems, which might be not just embedding
stuff. But, please file bugs of newly integrated embedding API at
http://kenai.com/jira/browse/JRUBY_EMBED.

    assertEquals("Wrong value came out on the Writer",

testString, stringWriter.toString().trim());
}
The test itself passes but we get a mystifying warning on stderr:
:1 warning: already initialized constant STDERR
As you can see, the script is a single line of code and it certainly isn’t
trying to define a constant, so I have to imagine every script gets this
warning.

I know this problem. Actually, JSR223 implementaion spits two
warnings, STDOUT and STDERR, but warning of STDOUT is gulped so that
users don’t confuse. However, warning of STDERR can’t be stopped on
current JRuby. If you use Embed Core, you won’t see the warning
because setWriter/setErrorWriter are totally transparent to the
implementation. While JSR223 impl is unable to know whether the error
writer in javax.script.ScriptContext is set by a user or not. So,
JSR223 implementation sets both writers for the first time. This is
why you got the warning.

I’ll seek the best way to stop the warning and file it since the
warnings are really noisy.

        StringWriter writer = new StringWriter();

be changed. :slight_smile:
Would you file this at kenai? Current implementation doesn’t handle
exceptions well and should improve.

-Yoko

TX


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs