NoMethodError does not give a useful message when thrown in BSF
---------------------------------------------------------------

                 Key: JRUBY-2905
                 URL: http://jira.codehaus.org/browse/JRUBY-2905
             Project: JRuby
          Issue Type: Bug
          Components: Java Integration
    Affects Versions: JRuby 1.1.3
         Environment: Seen on OS X 10.5.4, Java 1.5.0_13, with BSF 2.3.0 or 
2.4.0
            Reporter: Rhett Sutphin
         Attachments: NameErrorBsf.tar.gz

When you call an invalid method in a script running through BSF, the exception 
message includes something like "#<NameError::Message:0x2b8b27>".  This makes 
it difficult to determine which method is causing the problem.  E.g., with this 
code:

{code}
import org.apache.bsf.BSFException;
import org.apache.bsf.BSFManager;

public class NameErrorDemo {
    static {
        BSFManager.registerScriptingEngine("ruby", 
"org.jruby.javasupport.bsf.JRubyEngine", new String[] { "rb" });
    }
    
    public static void main(String[] argv) throws Throwable {
        BSFManager bsf = new BSFManager();
        bsf.exec("ruby", "(java)", 0, 0, "'test'.invalid_method");
    }
}
{code}

I get this exception:

{noformat}
<script>:1: #<NameError::Message:0x2b8b27> (NoMethodError)
        ...internal jruby stack elided...
Exception in thread "main" org.apache.bsf.BSFException: Exception
        at org.jruby.javasupport.bsf.JRubyEngine.exec(JRubyEngine.java:120)
        at org.apache.bsf.BSFManager$6.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.apache.bsf.BSFManager.exec(Unknown Source)
        at bugs.NameErrorDemo.main(NameErrorDemo.java:13)
{noformat}

A similar call in (jruby) irb does not have this problem:

{noformat}
irb(main):001:0> 'test'.invalid_method
NoMethodError: undefined method `invalid_method' for "test":String
        from (irb):2
{noformat}

The attached buildr project includes a test case illustrating this issue as 
well as the above code.

-- 
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