Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

"load" fails when calling scripts from command-line

#87

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.

Reported by Eric Clemmons · January 13th, 2010 @ 05:01 PM

State: resolved
Milestone: 1.2.x
Assigned to: Thatcher Thatcher

Activity

  1. Eric Clemmons
    Eric Clemmons

    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

    January 13th, 2010 @ 05:09 PM

  2. Brian Landau
    Brian Landau

    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.

    January 27th, 2010 @ 05:09 AM

  3. Thatcher
    Thatcher
    • 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

    February 3rd, 2010 @ 05:02 PM

  4. Thatcher
    Thatcher
    • State changed from open to resolved
    • Tag set to optimization, parser, rhino

    February 6th, 2010 @ 07:04 AM

  5. Doug McInnes
    Doug McInnes

    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
    

    May 17th, 2010 @ 01:34 PM

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.