RaiseException.printStackTrace() gives RaiseException: can't convert nil into 
String
------------------------------------------------------------------------------------

                 Key: JRUBY-3961
                 URL: http://jira.codehaus.org/browse/JRUBY-3961
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.3.1
            Reporter: Trejkaz


I constructed a unit test like this:

    @Test
    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();
            // Neither printStackTrace nor toString should throw exceptions.
            cause.toString();
            //noinspection IOResourceOpenedButNotSafelyClosed
            cause.printStackTrace(new PrintWriter(new StringWriter()));
        }
    }

This fails at printStackTrace with:

org.jruby.exceptions.RaiseException: can't convert nil into String
:1: can't convert nil into String (TypeError)
        ...internal jruby stack elided...
        from (unknown).(unknown)(:1)
        from (unknown).(unknown)(:1)

It gets to here in RaiseException:

        if (runtime.getNil() != backtrace) {
            String firstLine = 
backtrace.callMethod(runtime.getCurrentContext(), 
"first").convertToString().toString();    // <- THIS LINE
            ps.print(firstLine + ": ");
        }

And then up to here in RubyBasicObject:

    public RubyString convertToString() {
        return (RubyString) TypeConverter.convertToType(this, 
getRuntime().getString(), "to_str");
    }

At that point I'm not sure what to do.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to