jakarta-bsf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jiger Patel" <jiger_...@hotmail.com>
Subject Re: Capturing sysin and sysout-FIXED
Date Fri, 13 Jun 2003 08:09:04 GMT
Hi Victor,

>Glad to hear your success. Apologies to have not been able to help
>out in time.

No Problem. :)

>I'll make the modifications to the JythonEngine as soon as source
>re-organization discussions are complete; if I understand
>correctly, the Javascript and Beanshell engines are encapsulating
>error messages in the BSFException, while Jython requires an
>additional level of redirection to retrieve the error. Please
>correct me if I am wrong.

Hmm ya well something like that. When I receive a BSFException in case of 
BeanShell/Jython, and I do bsfexception.getMessage(), I get Beanshells 
original error message and no target exception object is set in bsfexception 
BUT in case of Javascript, I have to go all the way upto the 
bsfexception.getTargetException().getMessage() to get the actual exception. 
Both the ways I am able to get the error messages with or without 
adornments(additional message prefix/suffixed by resp. engines), but ideally 
the behaviours must be standard ideally like Javascript. To help you make 
out more better what I mean to say, I printed out the exceptions for 

[debug] Caught BSFException in executeScript org.apache.bsf.BSFException: 
JavaScript Error: Internal Error: ReferenceError: "sadfsad" is not defined.
[debug] exp.getMessage()JavaScript Error: Internal Error: ReferenceError: 
"sadfsad" is not defined.
[debug] exp.getTargetException() ReferenceError: "sadfsad" is not defined.
[debug] targetexception.getMessage() "sadfsad" is not defined.

Now when I run the same thing via Beanshell/Jython I get different result 
with minor difference within themselves too.

[debug]  Caught BSFException in executeScript org.apache.bsf.BSFException: 
exception from Jython: Traceback (innermost last):
[debug]    File "<string>", line 1, in ?
[debug]  NameError: fds
[debug]  exp.getMessage()exception from Jython: Traceback (innermost last):
[debug]    File "<string>", line 1, in ?
[debug]  NameError: fds
[debug]  exp.getTargetException() Traceback (innermost last):
[debug]    File "<string>", line 1, in ?
[debug]  NameError: fds
[debug]  targetexception.getMessage() null

The funniest of all is Beanshell which throws no exception if it cannot run 
the command, like for example when I ran the above string as command with 
language set to Beanshell, it gave me no exception in eval nor in exec!!! 

Well but I have completely revamped the Plugin code in 0.3 release and now 
it seems to be totally independent of the engines behaviour still making ALL 
engines behaviour standard vis-a-vis common things like Exception handling, 
returning values etc would definately help and make developers like me lifes 

Some more issues below

Here is a comment from my Plugin's code
//Last condition is due to JS hack. Coz it prints to the sysout AND also 
returns object of type Undefined.

This is the behaviour when doing a bsfmanager.eval(). Things like these are 
very tricky to handle and leads to hacks. Like I currently have a special 
hack for Jython. When the user selects Jython as his scripting languages, 
Jython does not load any classes from its classloader or contextClassLoader 
but from system classpath. Now since the plugin classes are dynamically 
loaded by the IDE's CL, they are not found and I have to explicitly call 
Py.getSystemState().addJar("path/to/plugin/jars"). This is really bad and 
ALL Engines to be BSF complaint must have a standard behaviour for 
ClassPaths, setting ClassLoaders, I/O, return values from eval/exec etc.

Thanks for all your help,

> > On the other note the Plugin seems to have fixed/introduce two major
> > enhancements and on my way to releasing a 0.2 release soon :)
> >
>Glad to hear it!
>Victor J. Orlikowski   | The Wall is Down, But the Threat Remains!
>orlikowski@apache.org  | vjo@dulug.duke.edu | vjo@us.ibm.com
>To unsubscribe, e-mail: bsf-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: bsf-dev-help@jakarta.apache.org

Narain Karthikeyan. He's fast, really fast. 
http://server1.msn.co.in/sp03/tataracing/index.asp Want to meet him?

View raw message