"load" fails when calling scripts from command-line
Reported by Eric Clemmons | January 13th, 2010 @ 05:01 PM | in 1.2.x
Suppose I have a script script.js
that consists
of:
load('env-js/dist/env.rhino.js');
print(typeof Envjs);
Calling java -jar env-js/dist/env-js.jar script.js
results in:
undefined
However, simply running java -jar
env-js/dist/env-js.jar
and pasting in
load('env-js/dist/env.rhino.js'); print(typeof Envjs);
results in:
function
I've poured over the test-prototype.sh file (along with others)
and it seems I'm not doing anything different than: java -cp
env-js.jar org.mozilla.javascript.tools.envjs.Main
test.js
I apologize if this is user error in anyway.
Comments and changes to this ticket
-
Eric Clemmons January 13th, 2010 @ 05:09 PM
Solution:
I had to turn on Optimization:
java -cp env-js/dist/env-js.jar org.mozilla.javascript.tools.envjs.Main -opt -1 script.js
-
Brian Landau January 27th, 2010 @ 05:09 AM
I can confirm that adding the
-opt -1
flags solves this problem.It seems like though if there's some way to not need to add these flags that would be more ideal.
-
Thatcher February 3rd, 2010 @ 05:02 PM
- Milestone set to 1.2.x
- State changed from new to open
- Assigned user set to Thatcher
We are going to build in a env.rhino.js context patch in javascript. It will only apply itself if the parser.js module is included. It's now more a mystery than ever why this occurs and I'll be following up with the rhino team to try to figure it out.
The bottom line is that we will patch internally so you wont notice.
Thatcher
-
Thatcher February 6th, 2010 @ 07:04 AM
- State changed from open to resolved
- Tag set to optimization, parser, rhino
ok this is fixed in trunk.
http://github.com/thatcher/env-js/commit/cd34da2405e2d5f6904cbf1651...
-
Doug McInnes May 17th, 2010 @ 01:34 PM
This still appears to be happening in the latest on trunk.
Adding -opt -1 to the java call does works around the problem.
Using the same script as above:
load('env-js/dist/env.rhino.js'); print(typeof Envjs); $ java -jar env-js/rhino/js.jar script.js undefined $ java -jar env-js/rhino/js.jar -opt -1 script.js [ Envjs/1.6 (Rhino; U; Mac OS X x86_64 10.5.8; en-US; rv:1.7.0.rc2) Resig/20070309 PilotFish/1.2.13 ] function
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
a javascript browser environment