RhinoScriptEngine (rhino 1.7.14 API)

org.mozilla.javascript.engine

## Class RhinoScriptEngine

- java.lang.Object
- - javax.script.AbstractScriptEngine
  - - org.mozilla.javascript.engine.RhinoScriptEngine

- All Implemented Interfaces:
    javax.script.Compilable, javax.script.Invocable, javax.script.ScriptEngine

      public class RhinoScriptEngine
      extends javax.script.AbstractScriptEngine
      implements javax.script.Compilable, javax.script.Invocable

  This is the implementation of the standard ScriptEngine interface for Rhino.

  An instance of the Rhino ScriptEngine is fully self-contained. Bindings at the GLOBAL_SCOPE may be set, but there is nothing special about them -- if both global and ENGINE_SCOPE bindings are set then the "engine" bindings override the global ones.

  The Rhino engine is not thread safe. Rhino does no synchronization of ScriptEngine instances and no synchronization of Bindings instances. It is up to the caller to ensure that the ScriptEngine and all its Bindings are used by a single thread at a time.

  The Rhino script engine includes some top-level built-in functions. See the Builtins class for more documentation.

  The engine supports a few configuration parameters that may be set at the "engine scope". Both are numbers that may be set to a String or Number object.

  - javax.script.language_version: The version of the JavaScript language supported, which is an integer defined in the Context class. The default is the latest "ES6" version, defined as 200.
  - org.mozilla.javascript.optimization_level: The level of optimization Rhino performs on the generated bytecode. Default is 9, which is the most. Set to -1 to use interpreted mode.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `OPTIMIZATION_LEVEL` Reserved key for the Rhino optimization level.

    - ### Fields inherited from class javax.script.AbstractScriptEngine

      `context`

    - ### Fields inherited from interface javax.script.ScriptEngine

      `ARGV, ENGINE, ENGINE_VERSION, FILENAME, LANGUAGE, LANGUAGE_VERSION, NAME`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `javax.script.CompiledScript` | `compile(java.io.Reader script)`
    `javax.script.CompiledScript` | `compile(java.lang.String script)`
    `javax.script.Bindings` | `createBindings()`
    `java.lang.Object` | `eval(java.io.Reader reader, javax.script.ScriptContext context)`
    `java.lang.Object` | `eval(java.lang.String script, javax.script.ScriptContext context)`
    `javax.script.ScriptEngineFactory` | `getFactory()`
    `<T> T` | `getInterface(java.lang.Class<T> clasz)`
    `<T> T` | `getInterface(java.lang.Object thiz, java.lang.Class<T> clasz)`
    `java.lang.Object` | `invokeFunction(java.lang.String name, java.lang.Object... args)`
    `java.lang.Object` | `invokeMethod(java.lang.Object thiz, java.lang.String name, java.lang.Object... args)`

    - ### Methods inherited from class javax.script.AbstractScriptEngine

      `eval, eval, eval, eval, get, getBindings, getContext, getScriptContext, put, setBindings, setContext`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### OPTIMIZATION_LEVEL

          public static final java.lang.String OPTIMIZATION_LEVEL

      Reserved key for the Rhino optimization level. Default is "9," for optimized and compiled code. Set this to "-1" to run Rhino in interpreted mode -- this is much much slower but the only option on platforms like Android that don't support class files.
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### eval

          public java.lang.Object eval(java.lang.String script,
                                       javax.script.ScriptContext context)
                                throws javax.script.ScriptException

      Specified by:
        `eval` in interface `javax.script.ScriptEngine`
      Throws:
        `javax.script.ScriptException`

    - #### eval

          public java.lang.Object eval(java.io.Reader reader,
                                       javax.script.ScriptContext context)
                                throws javax.script.ScriptException

      Specified by:
        `eval` in interface `javax.script.ScriptEngine`
      Throws:
        `javax.script.ScriptException`

    - #### compile

          public javax.script.CompiledScript compile(java.lang.String script)
                                              throws javax.script.ScriptException

      Specified by:
        `compile` in interface `javax.script.Compilable`
      Throws:
        `javax.script.ScriptException`

    - #### compile

          public javax.script.CompiledScript compile(java.io.Reader script)
                                              throws javax.script.ScriptException

      Specified by:
        `compile` in interface `javax.script.Compilable`
      Throws:
        `javax.script.ScriptException`

    - #### invokeFunction

          public java.lang.Object invokeFunction(java.lang.String name,
                                                 java.lang.Object... args)
                                          throws javax.script.ScriptException,
                                                 java.lang.NoSuchMethodException

      Specified by:
        `invokeFunction` in interface `javax.script.Invocable`
      Throws:
        `javax.script.ScriptException`
        `java.lang.NoSuchMethodException`

    - #### invokeMethod

          public java.lang.Object invokeMethod(java.lang.Object thiz,
                                               java.lang.String name,
                                               java.lang.Object... args)
                                        throws javax.script.ScriptException,
                                               java.lang.NoSuchMethodException

      Specified by:
        `invokeMethod` in interface `javax.script.Invocable`
      Throws:
        `javax.script.ScriptException`
        `java.lang.NoSuchMethodException`

    - #### getInterface

          public <T> T getInterface(java.lang.Class<T> clasz)

      Specified by:
        `getInterface` in interface `javax.script.Invocable`

    - #### getInterface

          public <T> T getInterface(java.lang.Object thiz,
                                    java.lang.Class<T> clasz)

      Specified by:
        `getInterface` in interface `javax.script.Invocable`

    - #### createBindings

          public javax.script.Bindings createBindings()

      Specified by:
        `createBindings` in interface `javax.script.ScriptEngine`

    - #### getFactory

          public javax.script.ScriptEngineFactory getFactory()

      Specified by:
        `getFactory` in interface `javax.script.ScriptEngine`