Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5984803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:25:58+00:00 2026-05-22T22:25:58+00:00

Ok, I think I found a bug in Rhino. I am trying to dynamically

  • 0

Ok, I think I found a bug in Rhino. I am trying to dynamically eval code in the global scope, and it works fine if I just do eval.call(null, “code to eval”); All was well until I tried to capture exceptions. When I surround that code with try/catch, the code is not actually eval’ed in the global context.

To illustrate the bug:

function works(str) {
  eval.call(null, str);
}

function doesntWork(str, count) {
  try {
    eval.call(null, str);
  } catch (e) {
    println('Error in ' + count + ' call: ' + e);
  }
}

works('var abc = 123;');
works('println("The value: " + abc);');
doesntWork('var xyz = 123;', 'first');
doesntWork('println("The value: " + xyz);', 'second');

When I run this in the Rhino built into OpenJDK 6, I get:

The value: 123
Error in second call: ReferenceError: "xyz" is not defined.

I was more convinced of this being a bug when I changed the println’s to console.log and ran it in Chrome, at which point I got 2 “The value: 123” logs, which is as I expect.

Furthermore, I looked up the ECMAScript standard and got this:

10.4.2 Entering Eval Code

The following steps are performed when
control enters the execution context
for eval code:

  1. If there is no calling context or if the eval code is not being
    evaluated by a direct call
    (15.1.2.1.1) to the eval function
    then,

    1. Initialize the execution context as if it was a global execution
      context using the eval code as C as
      described in 10.4.1.1.
  2. Else,
    1. Set the ThisBinding to the same value as the ThisBinding of the
      calling execution context.
    2. Set the LexicalEnvironment to the same value as the LexicalEnvironment
      of the calling execution context.
    3. Set the VariableEnvironment to the same value as the
      VariableEnvironment of the calling
      execution context.
  3. If the eval code is strict code, then
    1. Let strictVarEnv be the result of calling NewDeclarativeEnvironment
      passing the LexicalEnvironment as the
      argument.
    2. Set the LexicalEnvironment to strictVarEnv.
    3. Set the VariableEnvironment to strictVarEnv.
  4. Perform Declaration Binding Instantiation as described in 10.5
    using the eval code.

The first point is my case, or “there is no calling context,” so this should be eval’ed in the global context, and my xyz variable should work fine.

Have I truly hit a Rhino bug, or am I missing something?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:25:59+00:00Added an answer on May 22, 2026 at 10:25 pm

    The Rhino code built into the JDK is really, really old, and it has lots of bugs that have been fixed (for a long time) in the current release of the software from Mozilla.

    If you’re starting a new project, I would strongly recommend that you look into what it’s like to integrate Rhino using only the from-Mozilla code, and just make believe that all the “ScriptEngine” stuff in 1.6 isn’t there (or, possibly, implement your own ScriptEngine code around the Mozilla stuff). Don’t make the same mistake I made. Twice. 🙁

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've gone through just about every property I can think of, but haven't found
I think I have found a bug in UIScrollView, but I want to check
I think I may have found a bug in PHP's crypt() function under Windows.
What if I think, that I found a bug in an open-source-app? What steps
We've found a bug in old code where connections aren't being closed. It's an
I think I've found a bug in IE's (IE8) handling for the for-in javascript
I found this page describing the Muenchian method, but I think I'm applying it
The PHP documentation can be found here , but I think it's rather lacking.
Often, I found OutOfMemoryException on IBM Websphere Application Server. I think this exception occur
It's another Visual Studio 2008 HTML formatting question...I think I have either found a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.