Hi there,
while doing some initial explorative experiments with JSR-223 I stumbled over a NPE in NetRexx with the following Java program that lists all javax.script languages and interrogates the most important information about them: Running it yields the following output (leaving JavaScript for comparison):import java.util.List; import javax.script.ScriptEngine; import javax.script.ScriptEngineFactory; import javax.script.ScriptEngineManager; public class ListScriptEngines { public static void main(String args[]) { ScriptEngineManager manager = new ScriptEngineManager(); List<ScriptEngineFactory> factories = manager.getEngineFactories(); for (ScriptEngineFactory factory : factories) { System.out.println("getEngineName:\t "+factory.getEngineName()); System.out.println("\tgetEngineVersion: "+factory.getEngineVersion()); System.out.println("\tgetLanguageName: "+factory.getLanguageName()); System.out.println("\tgetLanguageVersion: "+factory.getLanguageVersion()); System.out.println("\tgetExtensions: "+factory.getExtensions()); System.out.println("\tgetMimeTypes: "+factory.getMimeTypes()); System.out.println("\tgetNames: "+factory.getNames()); System.out.print ("\tgetParameter(\"THREADING\"): "); System.out.println(factory.getParameter("THREADING")); System.out.println("----------------------"); } } } Posting here, because I do not know where to file the bug otherwise and being a little bit tight on time.F:\work\svn\bsf4oorexx\trunk\bsf4oorexx.dev\source_java\jsr223tests>java ListScriptEngines getEngineName: Mozilla Rhino getEngineVersion: 1.7 release 3 PRERELEASE getLanguageName: ECMAScript getLanguageVersion: 1.8 getExtensions: [js] getMimeTypes: [application/javascript, application/ecmascript, text/javascript, text/ecmascript] getNames: [js, rhino, JavaScript, javascript, ECMAScript, ecmascript] test nul ): null getParameter("THREADING"): MULTITHREADED ---------------------- getEngineName: NetRexx Script Engine getEngineVersion: V1.0.0 getLanguageName: NetRexx getLanguageVersion: 3.03 getExtensions: [.nrx] getMimeTypes: [text/plain, text/NetRexx, application/NetRexx] getNames: [NetRexx, netrexx] getParameter("THREADING"): Exception in thread "main" java.lang.NullPointerException at org.netrexx.jsr223.NetRexxScriptEngineFactory.getParameter(Unknown Source) at ListScriptEngines.main(ListScriptEngines.java:50) ---rony _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Hi Rony,
thanks for reporting this. I reproduced and opened issue https://kenai.com/jira/browse/NETREXX-117 for you. I also fixed it. It is in rev 509 of trunk. I don’t know if you build from source. If Kermit agrees with my fix I’ll resolve the issue in JIRA and will put up a new build of the hitherto unreleased 3.04 on the web page. best regards, René.
_______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Actually the error was in the NetRexxScriptEngineFactory
getParameter method which is supposed to return an object rather
than an object.toString. Here is the info from the Java 7 docs for
ScriptEngineFactory which shows that the "THREADING" null value is
correct for non threaded jsr223 implementations:
Object getParameter(String key) Returns the value of an attribute whose meaning
may be implementation-specific. Keys for which the value is
defined in all implementations are:
The values for these keys are the Strings returned by
import java.util.List; import javax.script.ScriptEngine; import javax.script.ScriptEngineFactory; import javax.script.ScriptEngineManager; class ListScriptEngines method main( args=String[]) static manager = ScriptEngineManager(); factories = manager.getEngineFactories(); factory=ScriptEngineFactory loop factory over factories Say "getEngineName:\t " factory.getEngineName() Say "\tgetEngineVersion: " factory.getEngineVersion() Say "\tgetLanguageName: " factory.getLanguageName() Say "\tgetLanguageVersion: " factory.getLanguageVersion() Say "\tgetExtensions: " factory.getExtensions() Say "\tgetMimeTypes: " factory.getMimeTypes() Say "\tgetNames: " factory.getNames() Say "\tgetParameter(\"THREADING\"): " Say factory.getParameter("THREADING") if factory.getParameter("THREADING")=null then say "its null" Say "----------------------" end ------------------------------------------------------------------------------------------------------------ I am currently researching JSR199, the Java Compiler API, to see if I can implement it for NetRexx compiles. If successful, the changes may allow us to implement more JSR223 features perhaps including multi-threading. I can see a possible need for that in server environments. Meanwhile the NPE fix is committed on trunk at rev 510. -- Kermit On 4/29/2015 11:23 AM, René Jansen
wrote:
Hi Rony, _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Free forum by Nabble | Edit this page |