Note also that "launcher" is a bookmark I am actively updating. It currently points to commit ID <8990376>, so you can use that if you don't want to hit a moving target. :)
-- David. On Mon, Jul 13, 2015 at 9:32 AM, David P. Caldwell <da...@code.davidpcaldwell.com> wrote: > Yes, this test "works" (as in demonstrates the problem): > > $ jrunscript -e > "load('https://bitbucket.org/api/1.0/repositories/davidpcaldwell/slime/raw/launcher/rhino/jrunscript/api.js?test=filename')" > stack = > https://bitbucket.org/api/1.0/repositories/davidpcaldwell/slime/raw/launcher/rhino/jrunscript/api.js?test=filename > javax.script.filename = <string> > > -- David. > > On Mon, Jul 13, 2015 at 8:59 AM, A. Sundararajan > <sundararajan.athijegannat...@oracle.com> wrote: >> Hi, >> >> AFAIK "javax.script.filename" is not set nashorn code anywhere. It is just >> read to find source name for engine.eval calls. >> >> "load" builtin is not related to jsr-223 API. It works regardless of jsr-223 >> usage and so it does not use (nor writes!) javax.script.filename property. >> >> Is there a source link (the links in your email give me "error") or a >> standalone test? >> >> Thanks, >> -Sundar >> >> >> >> On Saturday 11 July 2015 01:59 AM, David P. Caldwell wrote: >>> >>> According to the documentation for javax.script.ScriptEngine, the key >>> javax.script.ScriptEngine.FILENAME should point to the current file >>> being executed. And it does, when executing a local file. >>> >>> But when executing a file from a URL using load(), it does not work. I >>> can reliably get the URL using some rigamarole (see below), but I'd >>> like a method that's portable across JDK 6-8 (or so). >>> >>> Here's the output of the following snippet when executing locally: >>> >>> Snippet: >>> Packages.java.lang.System.out.println("stack = " + new >>> Packages.java.lang.Throwable().getStackTrace()[0].getFileName()); >>> var global = (function() { return this; })(); >>> Packages.java.lang.System.out.println("javax.script.filename = " + >>> global[String(Packages.javax.script.ScriptEngine.FILENAME)]); >>> >>> Output under JDK 8 locally: >>> stack = rhino/jrunscript/api.js >>> javax.script.filename = rhino/jrunscript/api.js >>> >>> Output under JDK 8 executing over HTTP via -e load('url'): >>> stack = >>> http://bitbucket.org/api/1.0/repositories/davidpcaldwell/jrunscript/raw/local/api.js?test=filename >>> javax.script.filename = <string> >>> >>> And further inspection indicates that's a *string* "<string>" >>> >>> Here's JDK 7 for comparison: >>> >>> Output under JDK 7 locally: >>> stack = NativeConstructorAccessorImpl.java >>> javax.script.filename = rhino/jrunscript/api.js >>> >>> Output under JDK 7 executing over HTTP via -e load('url'): >>> stack = NativeConstructorAccessorImpl.java >>> javax.script.filename = >>> >>> http://bitbucket.org/api/1.0/repositories/davidpcaldwell/jrunscript/raw/local/api.js?test=filename >>> >>> Thoughts? >>> >>> -- David P. Caldwell >>> http://www.davidpcaldwell.com/ >> >>