org.mozilla.javascript

## 类 Context

- java.lang.Object
- - org.mozilla.javascript.Context

- 直接已知子类:
    KContext

      public class Context
      extends java.lang.Object

  This class represents the runtime context of an executing script. Before executing a script, an instance of Context must be created and associated with the thread that will be executing the script. The Context will be used to store information about the executing of the script such as the call stack. Contexts are associated with the current thread using the `call(ContextAction)` or `enter()` methods.

  Different forms of script execution are supported. Scripts may be evaluated from the source directly, or first compiled and then later executed. Interactive execution is also supported.

  Some aspects of script execution, such as type conversions and object creation, may be accessed directly through methods of Context.

  另请参阅:
    `Scriptable`

- - ### 嵌套类概要

    嵌套类
    限定符和类型 | 类和说明
    --- | ---
    `static interface` | `Context.ClassShutterSetter`

  - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `static java.lang.Object[]` | `emptyArgs` Convenient value to use as zero-length array of objects.
    `static java.lang.String` | `errorReporterProperty`
    `static int` | `FEATURE_DYNAMIC_SCOPE` Control if dynamic scope should be used for name access.
    `static int` | `FEATURE_E4X` Control if support for E4X(ECMAScript for XML) extension is available.
    `static int` | `FEATURE_ENHANCED_JAVA_ACCESS` Enables enhanced access to Java.
    `static int` | `FEATURE_LOCATION_INFORMATION_IN_ERROR` When the feature is on Rhino will add a "fileName" and "lineNumber" properties to Error objects automatically.
    `static int` | `FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME` Control if member expression as function name extension is available.
    `static int` | `FEATURE_NON_ECMA_GET_YEAR` Controls behaviour of `Date.prototype.getYear()`.
    `static int` | `FEATURE_PARENT_PROTO_PROPERTIES` Control if properties `__proto__` and `__parent__` are treated specially.
    `static int` | `FEATURE_PARENT_PROTO_PROPRTIES` 已过时。 In previous releases, this name was given to FEATURE_PARENT_PROTO_PROPERTIES.
    `static int` | `FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER` Control if reserved keywords are treated as identifiers.
    `static int` | `FEATURE_STRICT_EVAL` Control if strict eval mode is enabled.
    `static int` | `FEATURE_STRICT_MODE` Controls whether JS 1.5 'strict mode' is enabled.
    `static int` | `FEATURE_STRICT_VARS` Control if strict variable mode is enabled.
    `static int` | `FEATURE_TO_STRING_AS_SOURCE` Control if `toString()` should returns the same result as `toSource()` when applied to objects and arrays.
    `static int` | `FEATURE_V8_EXTENSIONS` Enables access to JavaScript features from ECMAscript 6 that are present in JavaScript engines that do not yet support version 6, such as V8.
    `static int` | `FEATURE_WARNING_AS_ERROR` Controls whether a warning should be treated as an error.
    `boolean` | `generateObserverCount`
    `static java.lang.String` | `languageVersionProperty`
    `static int` | `VERSION_1_0` JavaScript 1.0
    `static int` | `VERSION_1_1` JavaScript 1.1
    `static int` | `VERSION_1_2` JavaScript 1.2
    `static int` | `VERSION_1_3` JavaScript 1.3
    `static int` | `VERSION_1_4` JavaScript 1.4
    `static int` | `VERSION_1_5` JavaScript 1.5
    `static int` | `VERSION_1_6` JavaScript 1.6
    `static int` | `VERSION_1_7` JavaScript 1.7
    `static int` | `VERSION_1_8` JavaScript 1.8
    `static int` | `VERSION_DEFAULT` The default version.
    `static int` | `VERSION_ES6` ECMAScript 6.
    `static int` | `VERSION_UNKNOWN` The unknown version.

  - ### 构造器概要

    构造器
    构造器和说明
    `Context()` 已过时。 this constructor is deprecated because it creates a dependency on a static singleton context factory. Use `ContextFactory.enter()` or `ContextFactory.call(ContextAction)` instead. If you subclass this class, consider using `Context(ContextFactory)` constructor instead in the subclasses' constructors.

  - ### 方法概要

    所有方法 静态方法 实例方法 具体方法 已过时的方法
    限定符和类型 | 方法和说明
    --- | ---
    `void` | `addActivationName(java.lang.String name)` Add a name to the list of names forcing the creation of real activation objects for functions.
    `static void` | `addContextListener(org.mozilla.javascript.ContextListener listener)` 已过时。
    `void` | `addPropertyChangeListener(java.beans.PropertyChangeListener l)` Register an object to receive notifications when a bound property has changed
    `static java.lang.Object` | `call(org.mozilla.javascript.ContextAction action)` 已过时。 use `ContextFactory.call(ContextAction)` instead as this method relies on usage of a static singleton "global" ContextFactory.
    `static java.lang.Object` | `call(org.mozilla.javascript.ContextFactory factory, org.mozilla.javascript.Callable callable, org.mozilla.javascript.Scriptable scope, org.mozilla.javascript.Scriptable thisObj, java.lang.Object[] args)` Call `Callable.call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args)` using the Context instance associated with the current thread.
    `java.lang.Object` | `callFunctionWithContinuations(org.mozilla.javascript.Callable function, org.mozilla.javascript.Scriptable scope, java.lang.Object[] args)` Call function that may pause execution by capturing a continuation.
    `org.mozilla.javascript.ContinuationPending` | `captureContinuation()` Capture a continuation from the current execution.
    `static void` | `checkLanguageVersion(int version)`
    `static void` | `checkOptimizationLevel(int optimizationLevel)`
    `org.mozilla.javascript.Function` | `compileFunction(org.mozilla.javascript.Scriptable scope, java.lang.String source, java.lang.String sourceName, int lineno, java.lang.Object securityDomain)` Compile a JavaScript function.
    `org.mozilla.javascript.Script` | `compileReader(java.io.Reader in, java.lang.String sourceName, int lineno, java.lang.Object securityDomain)` Compiles the source in the given reader.
    `org.mozilla.javascript.Script` | `compileReader(org.mozilla.javascript.Scriptable scope, java.io.Reader in, java.lang.String sourceName, int lineno, java.lang.Object securityDomain)` 已过时。
    `org.mozilla.javascript.Script` | `compileString(java.lang.String source, java.lang.String sourceName, int lineno, java.lang.Object securityDomain)` Compiles the source in the given string.
    `org.mozilla.javascript.GeneratedClassLoader` | `createClassLoader(java.lang.ClassLoader parent)` Create class loader for generated classes.
    `java.lang.String` | `decompileFunction(org.mozilla.javascript.Function fun, int indent)` Decompile a JavaScript Function.
    `java.lang.String` | `decompileFunctionBody(org.mozilla.javascript.Function fun, int indent)` Decompile the body of a JavaScript Function.
    `java.lang.String` | `decompileScript(org.mozilla.javascript.Script script, int indent)` Decompile the script.
    `static Context` | `enter()` Same as calling `ContextFactory.enterContext()` on the global ContextFactory instance.
    `static Context` | `enter(Context cx)` 已过时。 use `ContextFactory.enterContext(Context)` instead as this method relies on usage of a static singleton "global" ContextFactory.
    `java.lang.Object` | `evaluateReader(org.mozilla.javascript.Scriptable scope, java.io.Reader in, java.lang.String sourceName, int lineno, java.lang.Object securityDomain)` Evaluate a reader as JavaScript source.
    `java.lang.Object` | `evaluateString(org.mozilla.javascript.Scriptable scope, java.lang.String source, java.lang.String sourceName, int lineno, java.lang.Object securityDomain)` Evaluate a JavaScript source string.
    `java.lang.Object` | `executeScriptWithContinuations(org.mozilla.javascript.Script script, org.mozilla.javascript.Scriptable scope)` Execute script that may pause execution by capturing a continuation.
    `static void` | `exit()` Exit a block of code requiring a Context.
    `java.lang.ClassLoader` | `getApplicationClassLoader()`
    `Context.ClassShutterSetter` | `getClassShutterSetter()`
    `static Context` | `getCurrentContext()` Get the current Context.
    `static org.mozilla.javascript.debug.DebuggableScript` | `getDebuggableView(org.mozilla.javascript.Script script)` Return DebuggableScript instance if any associated with the script.
    `org.mozilla.javascript.debug.Debugger` | `getDebugger()` Return the current debugger.
    `java.lang.Object` | `getDebuggerContextData()` Return the debugger context data associated with current context.
    `org.mozilla.javascript.xml.XMLLib.Factory` | `getE4xImplementationFactory()` Returns an object which specifies an E4X implementation to use within this `Context`.
    `java.lang.Object[]` | `getElements(org.mozilla.javascript.Scriptable object)` Get the elements of a JavaScript array.
    `org.mozilla.javascript.ErrorReporter` | `getErrorReporter()` Get the current error reporter.
    `org.mozilla.javascript.ContextFactory` | `getFactory()` Return `ContextFactory` instance used to create this Context.
    `java.lang.String` | `getImplementationVersion()` Get the implementation version.
    `int` | `getInstructionObserverThreshold()` Get threshold of executed instructions counter that triggers call to `observeInstructionCount()`.
    `int` | `getLanguageVersion()` Get the current language version.
    `java.util.Locale` | `getLocale()` Get the current locale.
    `int` | `getMaximumInterpreterStackDepth()` Returns the maximum stack depth (in terms of number of call frames) allowed in a single invocation of interpreter.
    `int` | `getOptimizationLevel()` Get the current optimization level.
    `java.lang.Object` | `getThreadLocal(java.lang.Object key)` Get a value corresponding to a key.
    `static java.lang.Object` | `getUndefinedValue()` Get the singleton object that represents the JavaScript Undefined value.
    `org.mozilla.javascript.WrapFactory` | `getWrapFactory()` Return the current WrapFactory, or null if none is defined.
    `boolean` | `hasFeature(int featureIndex)` Controls certain aspects of script semantics.
    `ScriptableObject` | `initSafeStandardObjects()` Initialize the standard objects, leaving out those that offer access directly to Java classes.
    `org.mozilla.javascript.Scriptable` | `initSafeStandardObjects(ScriptableObject scope)` Initialize the standard objects, leaving out those that offer access directly to Java classes.
    `ScriptableObject` | `initSafeStandardObjects(ScriptableObject scope, boolean sealed)` Initialize the standard objects, leaving out those that offer access directly to Java classes.
    `ScriptableObject` | `initStandardObjects()` Initialize the standard objects.
    `org.mozilla.javascript.Scriptable` | `initStandardObjects(ScriptableObject scope)` Initialize the standard objects.
    `ScriptableObject` | `initStandardObjects(ScriptableObject scope, boolean sealed)` Initialize the standard objects.
    `boolean` | `isActivationNeeded(java.lang.String name)` Check whether the name is in the list of names of objects forcing the creation of activation objects.
    `boolean` | `isDebugModel()`
    `boolean` | `isGeneratingDebug()` Tell whether debug information is being generated.
    `boolean` | `isGeneratingDebugChanged()`
    `boolean` | `isGeneratingSource()` Tell whether source information is being generated.
    `boolean` | `isSealed()` Checks if this is a sealed Context.
    `static boolean` | `isValidLanguageVersion(int version)`
    `static boolean` | `isValidOptimizationLevel(int optimizationLevel)`
    `static java.lang.Object` | `javaToJS(java.lang.Object value, org.mozilla.javascript.Scriptable scope)` Convenient method to convert java value to its closest representation in JavaScript.
    `static java.lang.Object` | `jsToJava(java.lang.Object value, java.lang.Class<?> desiredType)` Convert a JavaScript value into the desired type.
    `org.mozilla.javascript.Scriptable` | `newArray(org.mozilla.javascript.Scriptable scope, int length)` Create an array with a specified initial length.
    `org.mozilla.javascript.Scriptable` | `newArray(org.mozilla.javascript.Scriptable scope, java.lang.Object[] elements)` Create an array with a set of initial elements.
    `org.mozilla.javascript.Scriptable` | `newObject(org.mozilla.javascript.Scriptable scope)` Create a new JavaScript object.
    `org.mozilla.javascript.Scriptable` | `newObject(org.mozilla.javascript.Scriptable scope, java.lang.String constructorName)` Create a new JavaScript object by executing the named constructor.
    `org.mozilla.javascript.Scriptable` | `newObject(org.mozilla.javascript.Scriptable scope, java.lang.String constructorName, java.lang.Object[] args)` Creates a new JavaScript object by executing the named constructor.
    `static java.lang.Object` | `original_jsToJava(java.lang.Object value, java.lang.Class<?> desiredType)`
    `void` | `putThreadLocal(java.lang.Object key, java.lang.Object value)` Put a value that can later be retrieved using a given key.
    `void` | `removeActivationName(java.lang.String name)` Remove a name from the list of names forcing the creation of real activation objects for functions.
    `static void` | `removeContextListener(org.mozilla.javascript.ContextListener listener)` 已过时。
    `void` | `removePropertyChangeListener(java.beans.PropertyChangeListener l)` Remove an object from the list of objects registered to receive notification of changes to a bounded property
    `void` | `removeThreadLocal(java.lang.Object key)` Remove values from thread-local storage.
    `static void` | `reportError(java.lang.String message)` Report an error using the error reporter for the current thread.
    `static void` | `reportError(java.lang.String message, java.lang.String sourceName, int lineno, java.lang.String lineSource, int lineOffset)` Report an error using the error reporter for the current thread.
    `static EvaluatorException` | `reportRuntimeError(java.lang.String message)` Report a runtime error using the error reporter for the current thread.
    `static EvaluatorException` | `reportRuntimeError(java.lang.String message, java.lang.String sourceName, int lineno, java.lang.String lineSource, int lineOffset)` Report a runtime error using the error reporter for the current thread.
    `static void` | `reportWarning(java.lang.String message)` Report a warning using the error reporter for the current thread.
    `static void` | `reportWarning(java.lang.String message, java.lang.String sourceName, int lineno, java.lang.String lineSource, int lineOffset)` Report a warning using the error reporter for the current thread.
    `static void` | `reportWarning(java.lang.String message, java.lang.Throwable t)`
    `java.lang.Object` | `resumeContinuation(java.lang.Object continuation, org.mozilla.javascript.Scriptable scope, java.lang.Object functionResult)` Restarts execution of the JavaScript suspended at the call to `captureContinuation()`.
    `void` | `seal(java.lang.Object sealKey)` Seal this Context object so any attempt to modify any of its properties including calling `enter()` and `exit()` methods will throw an exception.
    `void` | `setApplicationClassLoader(java.lang.ClassLoader loader)`
    `static void` | `setCachingEnabled(boolean cachingEnabled)` 已过时。
    `void` | `setClassShutter(org.mozilla.javascript.ClassShutter shutter)` Set the LiveConnect access filter for this context.
    `void` | `setDebugger(org.mozilla.javascript.debug.Debugger debugger, java.lang.Object contextData)` Set the associated debugger.
    `org.mozilla.javascript.ErrorReporter` | `setErrorReporter(org.mozilla.javascript.ErrorReporter reporter)` Change the current error reporter.
    `void` | `setGenerateObserverCount(boolean generateObserverCount)` Turn on or off generation of code with callbacks to track the count of executed instructions.
    `void` | `setGeneratingDebug(boolean generatingDebug)` Specify whether or not debug information should be generated.
    `void` | `setGeneratingSource(boolean generatingSource)` Specify whether or not source information should be generated.
    `void` | `setInstructionObserverThreshold(int threshold)` Set threshold of executed instructions counter that triggers call to `observeInstructionCount()`.
    `void` | `setLanguageVersion(int version)` Set the language version.
    `java.util.Locale` | `setLocale(java.util.Locale loc)` Set the current locale.
    `void` | `setMaximumInterpreterStackDepth(int max)` Sets the maximum stack depth (in terms of number of call frames) allowed in a single invocation of interpreter.
    `void` | `setOptimizationLevel(int optimizationLevel)` Set the current optimization level.
    `void` | `setSecurityController(org.mozilla.javascript.SecurityController controller)` Set the security controller for this context.
    `void` | `setWrapFactory(org.mozilla.javascript.WrapFactory wrapFactory)` Set a WrapFactory for this Context.
    `boolean` | `stringIsCompilableUnit(java.lang.String source)` Check whether a string is ready to be compiled.
    `static java.lang.RuntimeException` | `throwAsScriptRuntimeEx(java.lang.Throwable e)` Rethrow the exception wrapping it as the script runtime exception.
    `static boolean` | `toBoolean(java.lang.Object value)` Convert the value to a JavaScript boolean value.
    `static double` | `toNumber(java.lang.Object value)` Convert the value to a JavaScript Number value.
    `static org.mozilla.javascript.Scriptable` | `toObject(java.lang.Object value, org.mozilla.javascript.Scriptable scope)` Convert the value to an JavaScript object value.
    `static org.mozilla.javascript.Scriptable` | `toObject(java.lang.Object value, org.mozilla.javascript.Scriptable scope, java.lang.Class<?> staticType)` 已过时。
    `static java.lang.String` | `toString(java.lang.Object value)` Convert the value to a JavaScript String value.
    `static java.lang.Object` | `toType(java.lang.Object value, java.lang.Class<?> desiredType)` 已过时。
    `void` | `unseal(java.lang.Object sealKey)` Unseal previously sealed Context object.

    - ### 从类继承的方法 java.lang.Object

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

- - ### 字段详细资料

    - #### VERSION_UNKNOWN

          public static final int VERSION_UNKNOWN

      The unknown version.
      另请参阅:
        常量字段值

    - #### VERSION_DEFAULT

          public static final int VERSION_DEFAULT

      The default version.
      另请参阅:
        常量字段值

    - #### VERSION_1_0

          public static final int VERSION_1_0

      JavaScript 1.0
      另请参阅:
        常量字段值

    - #### VERSION_1_1

          public static final int VERSION_1_1

      JavaScript 1.1
      另请参阅:
        常量字段值

    - #### VERSION_1_2

          public static final int VERSION_1_2

      JavaScript 1.2
      另请参阅:
        常量字段值

    - #### VERSION_1_3

          public static final int VERSION_1_3

      JavaScript 1.3
      另请参阅:
        常量字段值

    - #### VERSION_1_4

          public static final int VERSION_1_4

      JavaScript 1.4
      另请参阅:
        常量字段值

    - #### VERSION_1_5

          public static final int VERSION_1_5

      JavaScript 1.5
      另请参阅:
        常量字段值

    - #### VERSION_1_6

          public static final int VERSION_1_6

      JavaScript 1.6
      另请参阅:
        常量字段值

    - #### VERSION_1_7

          public static final int VERSION_1_7

      JavaScript 1.7
      另请参阅:
        常量字段值

    - #### VERSION_1_8

          public static final int VERSION_1_8

      JavaScript 1.8
      另请参阅:
        常量字段值

    - #### VERSION_ES6

          public static final int VERSION_ES6

      ECMAScript 6.
      另请参阅:
        常量字段值

    - #### FEATURE_NON_ECMA_GET_YEAR

          public static final int FEATURE_NON_ECMA_GET_YEAR

      Controls behaviour of `Date.prototype.getYear()`. If `hasFeature(FEATURE_NON_ECMA_GET_YEAR)` returns true, Date.prototype.getYear subtructs 1900 only if 1900 <= date < 2000. The default behavior of `hasFeature(int)` is always to subtruct 1900 as rquired by ECMAScript B.2.4.
      另请参阅:
        常量字段值

    - #### FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME

          public static final int FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME

      Control if member expression as function name extension is available. If `hasFeature(FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME)` returns true, allow `function memberExpression(args) { body }` to be syntax sugar for `memberExpression = function(args) { body }`, when memberExpression is not a simple identifier. See ECMAScript-262, section 11.2 for definition of memberExpression. By default `hasFeature(int)` returns false.
      另请参阅:
        常量字段值

    - #### FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER

          public static final int FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER

      Control if reserved keywords are treated as identifiers. If `hasFeature(RESERVED_KEYWORD_AS_IDENTIFIER)` returns true, treat future reserved keyword (see Ecma-262, section 7.5.3) as ordinary identifiers but warn about this usage. By default `hasFeature(int)` returns false.
      另请参阅:
        常量字段值

    - #### FEATURE_TO_STRING_AS_SOURCE

          public static final int FEATURE_TO_STRING_AS_SOURCE

      Control if `toString()` should returns the same result as `toSource()` when applied to objects and arrays. If `hasFeature(FEATURE_TO_STRING_AS_SOURCE)` returns true, calling `toString()` on JS objects gives the same result as calling `toSource()`. That is it returns JS source with code to create an object with all enumeratable fields of the original object instead of printing `[object result of `Scriptable.getClassName()`]`.

      By default `hasFeature(int)` returns true only if the current JS version is set to `VERSION_1_2`.

      另请参阅:
        常量字段值

    - #### FEATURE_PARENT_PROTO_PROPERTIES

          public static final int FEATURE_PARENT_PROTO_PROPERTIES

      Control if properties `__proto__` and `__parent__` are treated specially. If `hasFeature(FEATURE_PARENT_PROTO_PROPERTIES)` returns true, treat `__parent__` and `__proto__` as special properties.

      The properties allow to query and set scope and prototype chains for the objects. The special meaning of the properties is available only when they are used as the right hand side of the dot operator. For example, while `x.__proto__ = y` changes the prototype chain of the object `x` to point to `y`, `x["__proto__"] = y` simply assigns a new value to the property `__proto__` in `x` even when the feature is on. By default `hasFeature(int)` returns true.

      另请参阅:
        常量字段值

    - #### FEATURE_PARENT_PROTO_PROPRTIES

          @Deprecated
          public static final int FEATURE_PARENT_PROTO_PROPRTIES

      已过时。 In previous releases, this name was given to FEATURE_PARENT_PROTO_PROPERTIES.
      另请参阅:
        常量字段值

    - #### FEATURE_E4X

          public static final int FEATURE_E4X

      Control if support for E4X(ECMAScript for XML) extension is available. If hasFeature(FEATURE_E4X) returns true, the XML syntax is available.

      By default `hasFeature(int)` returns true if the current JS version is set to `VERSION_DEFAULT` or is at least `VERSION_1_6`.

      从以下版本开始:
        1.6 Release 1
      另请参阅:
        常量字段值

    - #### FEATURE_DYNAMIC_SCOPE

          public static final int FEATURE_DYNAMIC_SCOPE

      Control if dynamic scope should be used for name access. If hasFeature(FEATURE_DYNAMIC_SCOPE) returns true, then the name lookup during name resolution will use the top scope of the script or function which is at the top of JS execution stack instead of the top scope of the script or function from the current stack frame if the top scope of the top stack frame contains the top scope of the current stack frame on its prototype chain.

      This is useful to define shared scope containing functions that can be called from scripts and functions using private scopes.

      By default `hasFeature(int)` returns false.

      从以下版本开始:
        1.6 Release 1
      另请参阅:
        常量字段值

    - #### FEATURE_STRICT_VARS

          public static final int FEATURE_STRICT_VARS

      Control if strict variable mode is enabled. When the feature is on Rhino reports runtime errors if assignment to a global variable that does not exist is executed. When the feature is off such assignments create a new variable in the global scope as required by ECMA 262.

      By default `hasFeature(int)` returns false.

      从以下版本开始:
        1.6 Release 1
      另请参阅:
        常量字段值

    - #### FEATURE_STRICT_EVAL

          public static final int FEATURE_STRICT_EVAL

      Control if strict eval mode is enabled. When the feature is on Rhino reports runtime errors if non-string argument is passed to the eval function. When the feature is off eval simply return non-string argument as is without performing any evaluation as required by ECMA 262.

      By default `hasFeature(int)` returns false.

      从以下版本开始:
        1.6 Release 1
      另请参阅:
        常量字段值

    - #### FEATURE_LOCATION_INFORMATION_IN_ERROR

          public static final int FEATURE_LOCATION_INFORMATION_IN_ERROR

      When the feature is on Rhino will add a "fileName" and "lineNumber" properties to Error objects automatically. When the feature is off, you have to explicitly pass them as the second and third argument to the Error constructor. Note that neither behavior is fully ECMA 262 compliant (as 262 doesn't specify a three-arg constructor), but keeping the feature off results in Error objects that don't have additional non-ECMA properties when constructed using the ECMA-defined single-arg constructor and is thus desirable if a stricter ECMA compliance is desired, specifically adherence to the point 15.11.5. of the standard.

      By default `hasFeature(int)` returns false.

      从以下版本开始:
        1.6 Release 6
      另请参阅:
        常量字段值

    - #### FEATURE_STRICT_MODE

          public static final int FEATURE_STRICT_MODE

      Controls whether JS 1.5 'strict mode' is enabled. When the feature is on, Rhino reports more than a dozen different warnings. When the feature is off, these warnings are not generated. FEATURE_STRICT_MODE implies FEATURE_STRICT_VARS and FEATURE_STRICT_EVAL.

      By default `hasFeature(int)` returns false.

      从以下版本开始:
        1.6 Release 6
      另请参阅:
        常量字段值

    - #### FEATURE_WARNING_AS_ERROR

          public static final int FEATURE_WARNING_AS_ERROR

      Controls whether a warning should be treated as an error.
      从以下版本开始:
        1.6 Release 6
      另请参阅:
        常量字段值

    - #### FEATURE_ENHANCED_JAVA_ACCESS

          public static final int FEATURE_ENHANCED_JAVA_ACCESS

      Enables enhanced access to Java. Specifically, controls whether private and protected members can be accessed, and whether scripts can catch all Java exceptions.

      Note that this feature should only be enabled for trusted scripts.

      By default `hasFeature(int)` returns false.

      从以下版本开始:
        1.7 Release 1
      另请参阅:
        常量字段值

    - #### FEATURE_V8_EXTENSIONS

          public static final int FEATURE_V8_EXTENSIONS

      Enables access to JavaScript features from ECMAscript 6 that are present in JavaScript engines that do not yet support version 6, such as V8. This includes support for typed arrays. Default is true.
      从以下版本开始:
        1.7 Release 3
      另请参阅:
        常量字段值

    - #### languageVersionProperty

          public static final java.lang.String languageVersionProperty

      另请参阅:
        常量字段值

    - #### errorReporterProperty

          public static final java.lang.String errorReporterProperty

      另请参阅:
        常量字段值

    - #### emptyArgs

          public static final java.lang.Object[] emptyArgs

      Convenient value to use as zero-length array of objects.

    - #### generateObserverCount

          public boolean generateObserverCount

  - ### 构造器详细资料

    - #### Context

          @Deprecated
          public Context()

      已过时。 this constructor is deprecated because it creates a dependency on a static singleton context factory. Use `ContextFactory.enter()` or `ContextFactory.call(ContextAction)` instead. If you subclass this class, consider using `Context(ContextFactory)` constructor instead in the subclasses' constructors.
      Creates a new Context. The context will be associated with the `global context factory`. Note that the Context must be associated with a thread before it can be used to execute a script.

  - ### 方法详细资料

    - #### getCurrentContext

          public static Context getCurrentContext()

      Get the current Context. The current Context is per-thread; this method looks up the Context associated with the current thread.

      返回:
        the Context associated with the current thread, or null if no context is associated with the current thread.
      另请参阅:
        `ContextFactory.enterContext()`, `ContextFactory.call(ContextAction)`

    - #### enter

          public static Context enter()

      Same as calling `ContextFactory.enterContext()` on the global ContextFactory instance.
      返回:
        a Context associated with the current thread
      另请参阅:
        `getCurrentContext()`, `exit()`, `call(ContextAction)`

    - #### enter

          @Deprecated
          public static Context enter(Context cx)

      已过时。 use `ContextFactory.enterContext(Context)` instead as this method relies on usage of a static singleton "global" ContextFactory.
      Get a Context associated with the current thread, using the given Context if need be.

      The same as `enter()` except that `cx` is associated with the current thread and returned if the current thread has no associated context and `cx` is not associated with any other thread.

      参数:
        `cx` - a Context to associate with the thread if possible
      返回:
        a Context associated with the current thread
      另请参阅:
        `ContextFactory.enterContext(Context)`, `ContextFactory.call(ContextAction)`

    - #### exit

          public static void exit()

      Exit a block of code requiring a Context. Calling `exit()` will remove the association between the current thread and a Context if the prior call to `ContextFactory.enterContext()` on this thread newly associated a Context with this thread. Once the current thread no longer has an associated Context, it cannot be used to execute JavaScript until it is again associated with a Context.
      另请参阅:
        `ContextFactory.enterContext()`

    - #### call

          @Deprecated
          public static java.lang.Object call(org.mozilla.javascript.ContextAction action)

      已过时。 use `ContextFactory.call(ContextAction)` instead as this method relies on usage of a static singleton "global" ContextFactory.
      Call `ContextAction.run(Context cx)` using the Context instance associated with the current thread. If no Context is associated with the thread, then `ContextFactory.getGlobal().makeContext()` will be called to construct new Context instance. The instance will be temporary associated with the thread during call to `ContextAction.run(Context)`.
      返回:
        The result of `ContextAction.run(Context)`.

    - #### call

          public static java.lang.Object call(org.mozilla.javascript.ContextFactory factory,
                                              org.mozilla.javascript.Callable callable,
                                              org.mozilla.javascript.Scriptable scope,
                                              org.mozilla.javascript.Scriptable thisObj,
                                              java.lang.Object[] args)

      Call `Callable.call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args)` using the Context instance associated with the current thread. If no Context is associated with the thread, then `ContextFactory.makeContext()` will be called to construct new Context instance. The instance will be temporary associated with the thread during call to `ContextAction.run(Context)`.

      It is allowed but not advisable to use null for `factory` argument in which case the global static singleton ContextFactory instance will be used to create new context instances.

      另请参阅:
        `ContextFactory.call(ContextAction)`

    - #### addContextListener

          @Deprecated
          public static void addContextListener(org.mozilla.javascript.ContextListener listener)

      已过时。
      另请参阅:
        `ContextFactory.addListener(org.mozilla.javascript.ContextFactory.Listener)`, `ContextFactory.getGlobal()`

    - #### removeContextListener

          @Deprecated
          public static void removeContextListener(org.mozilla.javascript.ContextListener listener)

      已过时。
      另请参阅:
        `ContextFactory.removeListener(org.mozilla.javascript.ContextFactory.Listener)`, `ContextFactory.getGlobal()`

    - #### getFactory

          public final org.mozilla.javascript.ContextFactory getFactory()

      Return `ContextFactory` instance used to create this Context.

    - #### isSealed

          public final boolean isSealed()

      Checks if this is a sealed Context. A sealed Context instance does not allow to modify any of its properties and will throw an exception on any such attempt.
      另请参阅:
        `seal(Object sealKey)`

    - #### seal

          public final void seal(java.lang.Object sealKey)

      Seal this Context object so any attempt to modify any of its properties including calling `enter()` and `exit()` methods will throw an exception.

      If `sealKey` is not null, calling `unseal(Object sealKey)` with the same key unseals the object. If `sealKey` is null, unsealing is no longer possible.

      另请参阅:
        `isSealed()`, `unseal(Object)`

    - #### unseal

          public final void unseal(java.lang.Object sealKey)

      Unseal previously sealed Context object. The `sealKey` argument should not be null and should match `sealKey` suplied with the last call to `seal(Object)` or an exception will be thrown.
      另请参阅:
        `isSealed()`, `seal(Object sealKey)`

    - #### getLanguageVersion

          public final int getLanguageVersion()

      Get the current language version.

      The language version number affects JavaScript semantics as detailed in the overview documentation.

      返回:
        an integer that is one of VERSION_1_0, VERSION_1_1, etc.

    - #### setLanguageVersion

          public void setLanguageVersion(int version)

      Set the language version.

      Setting the language version will affect functions and scripts compiled subsequently. See the overview documentation for version-specific behavior.

      参数:
        `version` - the version as specified by VERSION_1_0, VERSION_1_1, etc.

    - #### isValidLanguageVersion

          public static boolean isValidLanguageVersion(int version)

    - #### checkLanguageVersion

          public static void checkLanguageVersion(int version)

    - #### getImplementationVersion

          public final java.lang.String getImplementationVersion()

      Get the implementation version.

      The implementation version is of the form

              "name langVer release relNum date"

      where name is the name of the product, langVer is the language version, relNum is the release number, and date is the release date for that specific release in the form "yyyy mm dd".
      返回:
        a string that encodes the product, language version, release number, and date.

    - #### getErrorReporter

          public final org.mozilla.javascript.ErrorReporter getErrorReporter()

      Get the current error reporter.
      另请参阅:
        `ErrorReporter`

    - #### setErrorReporter

          public final org.mozilla.javascript.ErrorReporter setErrorReporter(org.mozilla.javascript.ErrorReporter reporter)

      Change the current error reporter.
      返回:
        the previous error reporter
      另请参阅:
        `ErrorReporter`

    - #### getLocale

          public final java.util.Locale getLocale()

      Get the current locale. Returns the default locale if none has been set.
      另请参阅:
        `Locale`

    - #### setLocale

          public final java.util.Locale setLocale(java.util.Locale loc)

      Set the current locale.
      另请参阅:
        `Locale`

    - #### addPropertyChangeListener

          public final void addPropertyChangeListener(java.beans.PropertyChangeListener l)

      Register an object to receive notifications when a bound property has changed
      参数:
        `l` - the listener
      另请参阅:
        `PropertyChangeEvent`, `removePropertyChangeListener(java.beans.PropertyChangeListener)`

    - #### removePropertyChangeListener

          public final void removePropertyChangeListener(java.beans.PropertyChangeListener l)

      Remove an object from the list of objects registered to receive notification of changes to a bounded property
      参数:
        `l` - the listener
      另请参阅:
        `PropertyChangeEvent`, `addPropertyChangeListener(java.beans.PropertyChangeListener)`

    - #### reportWarning

          public static void reportWarning(java.lang.String message,
                                           java.lang.String sourceName,
                                           int lineno,
                                           java.lang.String lineSource,
                                           int lineOffset)

      Report a warning using the error reporter for the current thread.
      参数:
        `message` - the warning message to report
        `sourceName` - a string describing the source, such as a filename
        `lineno` - the starting line number
        `lineSource` - the text of the line (may be null)
        `lineOffset` - the offset into lineSource where problem was detected
      另请参阅:
        `ErrorReporter`

    - #### reportWarning

          public static void reportWarning(java.lang.String message)

      Report a warning using the error reporter for the current thread.
      参数:
        `message` - the warning message to report
      另请参阅:
        `ErrorReporter`

    - #### reportWarning

          public static void reportWarning(java.lang.String message,
                                           java.lang.Throwable t)

    - #### reportError

          public static void reportError(java.lang.String message,
                                         java.lang.String sourceName,
                                         int lineno,
                                         java.lang.String lineSource,
                                         int lineOffset)

      Report an error using the error reporter for the current thread.
      参数:
        `message` - the error message to report
        `sourceName` - a string describing the source, such as a filename
        `lineno` - the starting line number
        `lineSource` - the text of the line (may be null)
        `lineOffset` - the offset into lineSource where problem was detected
      另请参阅:
        `ErrorReporter`

    - #### reportError

          public static void reportError(java.lang.String message)

      Report an error using the error reporter for the current thread.
      参数:
        `message` - the error message to report
      另请参阅:
        `ErrorReporter`

    - #### reportRuntimeError

          public static EvaluatorException reportRuntimeError(java.lang.String message,
                                                              java.lang.String sourceName,
                                                              int lineno,
                                                              java.lang.String lineSource,
                                                              int lineOffset)

      Report a runtime error using the error reporter for the current thread.
      参数:
        `message` - the error message to report
        `sourceName` - a string describing the source, such as a filename
        `lineno` - the starting line number
        `lineSource` - the text of the line (may be null)
        `lineOffset` - the offset into lineSource where problem was detected
      返回:
        a runtime exception that will be thrown to terminate the execution of the script
      另请参阅:
        `ErrorReporter`

    - #### reportRuntimeError

          public static EvaluatorException reportRuntimeError(java.lang.String message)

      Report a runtime error using the error reporter for the current thread.
      参数:
        `message` - the error message to report
      另请参阅:
        `ErrorReporter`

    - #### initStandardObjects

          public final ScriptableObject initStandardObjects()

      Initialize the standard objects. Creates instances of the standard objects and their constructors (Object, String, Number, Date, etc.), setting up 'scope' to act as a global object as in ECMA 15.1.

      This method must be called to initialize a scope before scripts can be evaluated in that scope.

      This method does not affect the Context it is called upon.

      返回:
        the initialized scope

    - #### initSafeStandardObjects

          public final ScriptableObject initSafeStandardObjects()

      Initialize the standard objects, leaving out those that offer access directly to Java classes. This sets up "scope" to have access to all the standard JavaScript classes, but does not create global objects for any top-level Java packages. In addition, the "Packages," "JavaAdapter," and "JavaImporter" classes, and the "getClass" function, are not initialized. The result of this function is a scope that may be safely used in a "sandbox" environment where it is not desirable to give access to Java code from JavaScript. Creates instances of the standard objects and their constructors (Object, String, Number, Date, etc.), setting up 'scope' to act as a global object as in ECMA 15.1.

      This method must be called to initialize a scope before scripts can be evaluated in that scope.

      This method does not affect the Context it is called upon.

      返回:
        the initialized scope

    - #### initStandardObjects

          public final org.mozilla.javascript.Scriptable initStandardObjects(ScriptableObject scope)

      Initialize the standard objects. Creates instances of the standard objects and their constructors (Object, String, Number, Date, etc.), setting up 'scope' to act as a global object as in ECMA 15.1.

      This method must be called to initialize a scope before scripts can be evaluated in that scope.

      This method does not affect the Context it is called upon.

      参数:
        `scope` - the scope to initialize, or null, in which case a new object will be created to serve as the scope
      返回:
        the initialized scope. The method returns the value of the scope argument if it is not null or newly allocated scope object which is an instance `ScriptableObject`.

    - #### initSafeStandardObjects

          public final org.mozilla.javascript.Scriptable initSafeStandardObjects(ScriptableObject scope)

      Initialize the standard objects, leaving out those that offer access directly to Java classes. This sets up "scope" to have access to all the standard JavaScript classes, but does not create global objects for any top-level Java packages. In addition, the "Packages," "JavaAdapter," and "JavaImporter" classes, and the "getClass" function, are not initialized. The result of this function is a scope that may be safely used in a "sandbox" environment where it is not desirable to give access to Java code from JavaScript. Creates instances of the standard objects and their constructors (Object, String, Number, Date, etc.), setting up 'scope' to act as a global object as in ECMA 15.1.

      This method must be called to initialize a scope before scripts can be evaluated in that scope.

      This method does not affect the Context it is called upon.

      参数:
        `scope` - the scope to initialize, or null, in which case a new object will be created to serve as the scope
      返回:
        the initialized scope. The method returns the value of the scope argument if it is not null or newly allocated scope object which is an instance `ScriptableObject`.

    - #### initStandardObjects

          public ScriptableObject initStandardObjects(ScriptableObject scope,
                                                      boolean sealed)

      Initialize the standard objects. Creates instances of the standard objects and their constructors (Object, String, Number, Date, etc.), setting up 'scope' to act as a global object as in ECMA 15.1.

      This method must be called to initialize a scope before scripts can be evaluated in that scope.

      This method does not affect the Context it is called upon.

      This form of the method also allows for creating "sealed" standard objects. An object that is sealed cannot have properties added, changed, or removed. This is useful to create a "superglobal" that can be shared among several top-level objects. Note that sealing is not allowed in the current ECMA/ISO language specification, but is likely for the next version.

      参数:
        `scope` - the scope to initialize, or null, in which case a new object will be created to serve as the scope
        `sealed` - whether or not to create sealed standard objects that cannot be modified.
      返回:
        the initialized scope. The method returns the value of the scope argument if it is not null or newly allocated scope object.
      从以下版本开始:
        1.4R3

    - #### initSafeStandardObjects

          public ScriptableObject initSafeStandardObjects(ScriptableObject scope,
                                                          boolean sealed)

      Initialize the standard objects, leaving out those that offer access directly to Java classes. This sets up "scope" to have access to all the standard JavaScript classes, but does not create global objects for any top-level Java packages. In addition, the "Packages," "JavaAdapter," and "JavaImporter" classes, and the "getClass" function, are not initialized. The result of this function is a scope that may be safely used in a "sandbox" environment where it is not desirable to give access to Java code from JavaScript. Creates instances of the standard objects and their constructors (Object, String, Number, Date, etc.), setting up 'scope' to act as a global object as in ECMA 15.1.

      This method must be called to initialize a scope before scripts can be evaluated in that scope.

      This method does not affect the Context it is called upon.

      This form of the method also allows for creating "sealed" standard objects. An object that is sealed cannot have properties added, changed, or removed. This is useful to create a "superglobal" that can be shared among several top-level objects. Note that sealing is not allowed in the current ECMA/ISO language specification, but is likely for the next version.

      参数:
        `scope` - the scope to initialize, or null, in which case a new object will be created to serve as the scope
        `sealed` - whether or not to create sealed standard objects that cannot be modified.
      返回:
        the initialized scope. The method returns the value of the scope argument if it is not null or newly allocated scope object.
      从以下版本开始:
        1.7.6

    - #### getUndefinedValue

          public static java.lang.Object getUndefinedValue()

      Get the singleton object that represents the JavaScript Undefined value.

    - #### evaluateString

          public final java.lang.Object evaluateString(org.mozilla.javascript.Scriptable scope,
                                                       java.lang.String source,
                                                       java.lang.String sourceName,
                                                       int lineno,
                                                       java.lang.Object securityDomain)

      Evaluate a JavaScript source string. The provided source name and line number are used for error messages and for producing debug information.
      参数:
        `scope` - the scope to execute in
        `source` - the JavaScript source
        `sourceName` - a string describing the source, such as a filename
        `lineno` - the starting line number
        `securityDomain` - an arbitrary object that specifies security information about the origin or owner of the script. For implementations that don't care about security, this value may be null.
      返回:
        the result of evaluating the string
      另请参阅:
        `SecurityController`

    - #### evaluateReader

          public final java.lang.Object evaluateReader(org.mozilla.javascript.Scriptable scope,
                                                       java.io.Reader in,
                                                       java.lang.String sourceName,
                                                       int lineno,
                                                       java.lang.Object securityDomain)
                                                throws java.io.IOException

      Evaluate a reader as JavaScript source. All characters of the reader are consumed.
      参数:
        `scope` - the scope to execute in
        `in` - the Reader to get JavaScript source from
        `sourceName` - a string describing the source, such as a filename
        `lineno` - the starting line number
        `securityDomain` - an arbitrary object that specifies security information about the origin or owner of the script. For implementations that don't care about security, this value may be null.
      返回:
        the result of evaluating the source
      抛出:
        `java.io.IOException` - if an IOException was generated by the Reader

    - #### executeScriptWithContinuations

          public java.lang.Object executeScriptWithContinuations(org.mozilla.javascript.Script script,
                                                                 org.mozilla.javascript.Scriptable scope)
                                                          throws org.mozilla.javascript.ContinuationPending

      Execute script that may pause execution by capturing a continuation. Caller must be prepared to catch a ContinuationPending exception and resume execution by calling `resumeContinuation(Object, Scriptable, Object)`.
      参数:
        `script` - The script to execute. Script must have been compiled with interpreted mode (optimization level -1)
        `scope` - The scope to execute the script against
      抛出:
        `ContinuationPending` - if the script calls a function that results in a call to `captureContinuation()`
      从以下版本开始:
        1.7 Release 2

    - #### callFunctionWithContinuations

          public java.lang.Object callFunctionWithContinuations(org.mozilla.javascript.Callable function,
                                                                org.mozilla.javascript.Scriptable scope,
                                                                java.lang.Object[] args)
                                                         throws org.mozilla.javascript.ContinuationPending

      Call function that may pause execution by capturing a continuation. Caller must be prepared to catch a ContinuationPending exception and resume execution by calling `resumeContinuation(Object, Scriptable, Object)`.
      参数:
        `function` - The function to call. The function must have been compiled with interpreted mode (optimization level -1)
        `scope` - The scope to execute the script against
        `args` - The arguments for the function
      抛出:
        `ContinuationPending` - if the script calls a function that results in a call to `captureContinuation()`
      从以下版本开始:
        1.7 Release 2

    - #### captureContinuation

          public org.mozilla.javascript.ContinuationPending captureContinuation()

      Capture a continuation from the current execution. The execution must have been started via a call to `executeScriptWithContinuations(Script, Scriptable)` or `callFunctionWithContinuations(Callable, Scriptable, Object[])`. This implies that the code calling this method must have been called as a function from the JavaScript script. Also, there cannot be any non-JavaScript code between the JavaScript frames (e.g., a call to eval()). The ContinuationPending exception returned must be thrown.
      返回:
        A ContinuationPending exception that must be thrown
      从以下版本开始:
        1.7 Release 2

    - #### resumeContinuation

          public java.lang.Object resumeContinuation(java.lang.Object continuation,
                                                     org.mozilla.javascript.Scriptable scope,
                                                     java.lang.Object functionResult)
                                              throws org.mozilla.javascript.ContinuationPending

      Restarts execution of the JavaScript suspended at the call to `captureContinuation()`. Execution of the code will resume with the functionResult as the result of the call that captured the continuation. Execution of the script will either conclude normally and the result returned, another continuation will be captured and thrown, or the script will terminate abnormally and throw an exception.
      参数:
        `continuation` - The value returned by `ContinuationPending.getContinuation()`
        `functionResult` - This value will appear to the code being resumed as the result of the function that captured the continuation
      抛出:
        `ContinuationPending` - if another continuation is captured before the code terminates
      从以下版本开始:
        1.7 Release 2

    - #### stringIsCompilableUnit

          public final boolean stringIsCompilableUnit(java.lang.String source)

      Check whether a string is ready to be compiled.

      stringIsCompilableUnit is intended to support interactive compilation of JavaScript. If compiling the string would result in an error that might be fixed by appending more source, this method returns false. In every other case, it returns true.

      Interactive shells may accumulate source lines, using this method after each new line is appended to check whether the statement being entered is complete.

      参数:
        `source` - the source buffer to check
      返回:
        whether the source is ready for compilation
      从以下版本开始:
        1.4 Release 2

    - #### compileReader

          @Deprecated
          public final org.mozilla.javascript.Script compileReader(org.mozilla.javascript.Scriptable scope,
                                                                                java.io.Reader in,
                                                                                java.lang.String sourceName,
                                                                                int lineno,
                                                                                java.lang.Object securityDomain)
                                                                         throws java.io.IOException

      已过时。
      抛出:
        `java.io.IOException`
      另请参阅:
        `compileReader(Reader in, String sourceName, int lineno, Object securityDomain)`

    - #### compileReader

          public final org.mozilla.javascript.Script compileReader(java.io.Reader in,
                                                                   java.lang.String sourceName,
                                                                   int lineno,
                                                                   java.lang.Object securityDomain)
                                                            throws java.io.IOException

      Compiles the source in the given reader.

      Returns a script that may later be executed. Will consume all the source in the reader.

      参数:
        `in` - the input reader
        `sourceName` - a string describing the source, such as a filename
        `lineno` - the starting line number for reporting errors
        `securityDomain` - an arbitrary object that specifies security information about the origin or owner of the script. For implementations that don't care about security, this value may be null.
      返回:
        a script that may later be executed
      抛出:
        `java.io.IOException` - if an IOException was generated by the Reader
      另请参阅:
        `Script`

    - #### compileString

          public final org.mozilla.javascript.Script compileString(java.lang.String source,
                                                                   java.lang.String sourceName,
                                                                   int lineno,
                                                                   java.lang.Object securityDomain)

      Compiles the source in the given string.

      Returns a script that may later be executed.

      参数:
        `source` - the source string
        `sourceName` - a string describing the source, such as a filename
        `lineno` - the starting line number for reporting errors. Use 0 if the line number is unknown.
        `securityDomain` - an arbitrary object that specifies security information about the origin or owner of the script. For implementations that don't care about security, this value may be null.
      返回:
        a script that may later be executed
      另请参阅:
        `Script`

    - #### compileFunction

          public final org.mozilla.javascript.Function compileFunction(org.mozilla.javascript.Scriptable scope,
                                                                       java.lang.String source,
                                                                       java.lang.String sourceName,
                                                                       int lineno,
                                                                       java.lang.Object securityDomain)

      Compile a JavaScript function.

      The function source must be a function definition as defined by ECMA (e.g., "function f(a) { return a; }").

      参数:
        `scope` - the scope to compile relative to
        `source` - the function definition source
        `sourceName` - a string describing the source, such as a filename
        `lineno` - the starting line number
        `securityDomain` - an arbitrary object that specifies security information about the origin or owner of the script. For implementations that don't care about security, this value may be null.
      返回:
        a Function that may later be called
      另请参阅:
        `Function`

    - #### decompileScript

          public final java.lang.String decompileScript(org.mozilla.javascript.Script script,
                                                        int indent)

      Decompile the script.

      The canonical source of the script is returned.

      参数:
        `script` - the script to decompile
        `indent` - the number of spaces to indent the result
      返回:
        a string representing the script source

    - #### decompileFunction

          public final java.lang.String decompileFunction(org.mozilla.javascript.Function fun,
                                                          int indent)

      Decompile a JavaScript Function.

      Decompiles a previously compiled JavaScript function object to canonical source.

      Returns function body of '[native code]' if no decompilation information is available.

      参数:
        `fun` - the JavaScript function to decompile
        `indent` - the number of spaces to indent the result
      返回:
        a string representing the function source

    - #### decompileFunctionBody

          public final java.lang.String decompileFunctionBody(org.mozilla.javascript.Function fun,
                                                              int indent)

      Decompile the body of a JavaScript Function.

      Decompiles the body a previously compiled JavaScript Function object to canonical source, omitting the function header and trailing brace. Returns '[native code]' if no decompilation information is available.

      参数:
        `fun` - the JavaScript function to decompile
        `indent` - the number of spaces to indent the result
      返回:
        a string representing the function body source.

    - #### newObject

          public org.mozilla.javascript.Scriptable newObject(org.mozilla.javascript.Scriptable scope)

      Create a new JavaScript object. Equivalent to evaluating "new Object()".
      参数:
        `scope` - the scope to search for the constructor and to evaluate against
      返回:
        the new object

    - #### newObject

          public org.mozilla.javascript.Scriptable newObject(org.mozilla.javascript.Scriptable scope,
                                                             java.lang.String constructorName)

      Create a new JavaScript object by executing the named constructor. The call `newObject(scope, "Foo")` is equivalent to evaluating "new Foo()".
      参数:
        `scope` - the scope to search for the constructor and to evaluate against
        `constructorName` - the name of the constructor to call
      返回:
        the new object

    - #### newObject

          public org.mozilla.javascript.Scriptable newObject(org.mozilla.javascript.Scriptable scope,
                                                             java.lang.String constructorName,
                                                             java.lang.Object[] args)

      Creates a new JavaScript object by executing the named constructor. Searches `scope` for the named constructor, calls it with the given arguments, and returns the result.

      The code

           Object[] args = { "a", "b" };
           newObject(scope, "Foo", args)

      is equivalent to evaluating "new Foo('a', 'b')", assuming that the Foo constructor has been defined in `scope`.
      参数:
        `scope` - The scope to search for the constructor and to evaluate against
        `constructorName` - the name of the constructor to call
        `args` - the array of arguments for the constructor
      返回:
        the new object

    - #### newArray

          public org.mozilla.javascript.Scriptable newArray(org.mozilla.javascript.Scriptable scope,
                                                            int length)

      Create an array with a specified initial length.

      参数:
        `scope` - the scope to create the object in
        `length` - the initial length (JavaScript arrays may have additional properties added dynamically).
      返回:
        the new array object

    - #### newArray

          public org.mozilla.javascript.Scriptable newArray(org.mozilla.javascript.Scriptable scope,
                                                            java.lang.Object[] elements)

      Create an array with a set of initial elements.
      参数:
        `scope` - the scope to create the object in.
        `elements` - the initial elements. Each object in this array must be an acceptable JavaScript type and type of array should be exactly Object[], not SomeObjectSubclass[].
      返回:
        the new array object.

    - #### getElements

          public final java.lang.Object[] getElements(org.mozilla.javascript.Scriptable object)

      Get the elements of a JavaScript array.

      If the object defines a length property convertible to double number, then the number is converted Uint32 value as defined in Ecma 9.6 and Java array of that size is allocated. The array is initialized with the values obtained by calling get() on object for each value of i in [0,length-1]. If there is not a defined value for a property the Undefined value is used to initialize the corresponding element in the array. The Java array is then returned. If the object doesn't define a length property or it is not a number, empty array is returned.

      参数:
        `object` - the JavaScript array or array-like object
      返回:
        a Java array of objects
      从以下版本开始:
        1.4 release 2

    - #### toBoolean

          public static boolean toBoolean(java.lang.Object value)

      Convert the value to a JavaScript boolean value.

      See ECMA 9.2.

      参数:
        `value` - a JavaScript value
      返回:
        the corresponding boolean value converted using the ECMA rules

    - #### toNumber

          public static double toNumber(java.lang.Object value)

      Convert the value to a JavaScript Number value.

      Returns a Java double for the JavaScript Number.

      See ECMA 9.3.

      参数:
        `value` - a JavaScript value
      返回:
        the corresponding double value converted using the ECMA rules

    - #### toString

          public static java.lang.String toString(java.lang.Object value)

      Convert the value to a JavaScript String value.

      See ECMA 9.8.

      参数:
        `value` - a JavaScript value
      返回:
        the corresponding String value converted using the ECMA rules

    - #### toObject

          public static org.mozilla.javascript.Scriptable toObject(java.lang.Object value,
                                                                   org.mozilla.javascript.Scriptable scope)

      Convert the value to an JavaScript object value.

      Note that a scope must be provided to look up the constructors for Number, Boolean, and String.

      See ECMA 9.9.

      Additionally, arbitrary Java objects and classes will be wrapped in a Scriptable object with its Java fields and methods reflected as JavaScript properties of the object.

      参数:
        `value` - any Java object
        `scope` - global scope containing constructors for Number, Boolean, and String
      返回:
        new JavaScript object

    - #### toObject

          @Deprecated
          public static org.mozilla.javascript.Scriptable toObject(java.lang.Object value,
                                                                                org.mozilla.javascript.Scriptable scope,
                                                                                java.lang.Class<?> staticType)

      已过时。
      另请参阅:
        `toObject(Object, Scriptable)`

    - #### javaToJS

          public static java.lang.Object javaToJS(java.lang.Object value,
                                                  org.mozilla.javascript.Scriptable scope)

      Convenient method to convert java value to its closest representation in JavaScript.

      If value is an instance of String, Number, Boolean, Function or Scriptable, it is returned as it and will be treated as the corresponding JavaScript type of string, number, boolean, function and object.

      Note that for Number instances during any arithmetic operation in JavaScript the engine will always use the result of `Number.doubleValue()` resulting in a precision loss if the number can not fit into double.

      If value is an instance of Character, it will be converted to string of length 1 and its JavaScript type will be string.

      The rest of values will be wrapped as LiveConnect objects by calling `WrapFactory.wrap(Context cx, Scriptable scope, Object obj, Class staticType)` as in:

              Context cx = Context.getCurrentContext();
              return cx.getWrapFactory().wrap(cx, scope, value, null);

      参数:
        `value` - any Java object
        `scope` - top scope object
      返回:
        value suitable to pass to any API that takes JavaScript values.

    - #### jsToJava

          public static java.lang.Object jsToJava(java.lang.Object value,
                                                  java.lang.Class<?> desiredType)
                                           throws EvaluatorException

      Convert a JavaScript value into the desired type. Uses the semantics defined with LiveConnect3 and throws an Illegal argument exception if the conversion cannot be performed.
      参数:
        `value` - the JavaScript value to convert
        `desiredType` - the Java type to convert to. Primitive Java types are represented using the TYPE fields in the corresponding wrapper class in java.lang.
      返回:
        the converted value
      抛出:
        `EvaluatorException` - if the conversion cannot be performed

    - #### original_jsToJava

          public static java.lang.Object original_jsToJava(java.lang.Object value,
                                                           java.lang.Class<?> desiredType)
                                                    throws EvaluatorException

      抛出:
        `EvaluatorException`

    - #### toType

          @Deprecated
          public static java.lang.Object toType(java.lang.Object value,
                                                             java.lang.Class<?> desiredType)
                                                      throws java.lang.IllegalArgumentException

      已过时。
      抛出:
        `java.lang.IllegalArgumentException` - if the conversion cannot be performed. Note that `jsToJava(Object, Class)` throws `EvaluatorException` instead.
      另请参阅:
        `jsToJava(Object, Class)`

    - #### throwAsScriptRuntimeEx

          public static java.lang.RuntimeException throwAsScriptRuntimeEx(java.lang.Throwable e)

      Rethrow the exception wrapping it as the script runtime exception. Unless the exception is instance of `EcmaError` or `EvaluatorException` it will be wrapped as `WrappedException`, a subclass of `EvaluatorException`. The resulting exception object always contains source name and line number of script that triggered exception.

      This method always throws an exception, its return value is provided only for convenience to allow a usage like:

           throw Context.throwAsScriptRuntimeEx(ex);

      to indicate that code after the method is unreachable.
      抛出:
        `EvaluatorException`
        `EcmaError`

    - #### isGeneratingDebug

          public final boolean isGeneratingDebug()

      Tell whether debug information is being generated.
      从以下版本开始:
        1.3

    - #### setGeneratingDebug

          public final void setGeneratingDebug(boolean generatingDebug)

      Specify whether or not debug information should be generated.

      Setting the generation of debug information on will set the optimization level to zero.

      从以下版本开始:
        1.3

    - #### isGeneratingSource

          public final boolean isGeneratingSource()

      Tell whether source information is being generated.
      从以下版本开始:
        1.3

    - #### setGeneratingSource

          public final void setGeneratingSource(boolean generatingSource)

      Specify whether or not source information should be generated.

      Without source information, evaluating the "toString" method on JavaScript functions produces only "[native code]" for the body of the function. Note that code generated without source is not fully ECMA conformant.

      从以下版本开始:
        1.3

    - #### getOptimizationLevel

          public final int getOptimizationLevel()

      Get the current optimization level.

      The optimization level is expressed as an integer between -1 and 9.

      从以下版本开始:
        1.3

    - #### setOptimizationLevel

          public final void setOptimizationLevel(int optimizationLevel)

      Set the current optimization level.

      The optimization level is expected to be an integer between -1 and 9. Any negative values will be interpreted as -1, and any values greater than 9 will be interpreted as 9. An optimization level of -1 indicates that interpretive mode will always be used. Levels 0 through 9 indicate that class files may be generated. Higher optimization levels trade off compile time performance for runtime performance. The optimizer level can't be set greater than -1 if the optimizer package doesn't exist at run time.

      参数:
        `optimizationLevel` - an integer indicating the level of optimization to perform
      从以下版本开始:
        1.3

    - #### isValidOptimizationLevel

          public static boolean isValidOptimizationLevel(int optimizationLevel)

    - #### checkOptimizationLevel

          public static void checkOptimizationLevel(int optimizationLevel)

    - #### getMaximumInterpreterStackDepth

          public final int getMaximumInterpreterStackDepth()

      Returns the maximum stack depth (in terms of number of call frames) allowed in a single invocation of interpreter. If the set depth would be exceeded, the interpreter will throw an EvaluatorException in the script. Defaults to Integer.MAX_VALUE. The setting only has effect for interpreted functions (those compiled with optimization level set to -1). As the interpreter doesn't use the Java stack but rather manages its own stack in the heap memory, a runaway recursion in interpreted code would eventually consume all available memory and cause OutOfMemoryError instead of a StackOverflowError limited to only a single thread. This setting helps prevent such situations.
      返回:
        The current maximum interpreter stack depth.

    - #### setMaximumInterpreterStackDepth

          public final void setMaximumInterpreterStackDepth(int max)

      Sets the maximum stack depth (in terms of number of call frames) allowed in a single invocation of interpreter. If the set depth would be exceeded, the interpreter will throw an EvaluatorException in the script. Defaults to Integer.MAX_VALUE. The setting only has effect for interpreted functions (those compiled with optimization level set to -1). As the interpreter doesn't use the Java stack but rather manages its own stack in the heap memory, a runaway recursion in interpreted code would eventually consume all available memory and cause OutOfMemoryError instead of a StackOverflowError limited to only a single thread. This setting helps prevent such situations.
      参数:
        `max` - the new maximum interpreter stack depth
      抛出:
        `java.lang.IllegalStateException` - if this context's optimization level is not -1
        `java.lang.IllegalArgumentException` - if the new depth is not at least 1

    - #### setSecurityController

          public final void setSecurityController(org.mozilla.javascript.SecurityController controller)

      Set the security controller for this context.

      SecurityController may only be set if it is currently null and `SecurityController.hasGlobal()` is `false`. Otherwise a SecurityException is thrown.

      参数:
        `controller` - a SecurityController object
      抛出:
        `java.lang.SecurityException` - if there is already a SecurityController object for this Context or globally installed.
      另请参阅:
        `SecurityController.initGlobal(SecurityController controller)`, `SecurityController.hasGlobal()`

    - #### setClassShutter

          public final void setClassShutter(org.mozilla.javascript.ClassShutter shutter)

      Set the LiveConnect access filter for this context.

      `ClassShutter` may only be set if it is currently null. Otherwise a SecurityException is thrown.

      参数:
        `shutter` - a ClassShutter object
      抛出:
        `java.lang.SecurityException` - if there is already a ClassShutter object for this Context

    - #### getClassShutterSetter

          public final Context.ClassShutterSetter getClassShutterSetter()

    - #### getThreadLocal

          public final java.lang.Object getThreadLocal(java.lang.Object key)

      Get a value corresponding to a key.

      Since the Context is associated with a thread it can be used to maintain values that can be later retrieved using the current thread.

      Note that the values are maintained with the Context, so if the Context is disassociated from the thread the values cannot be retrieved. Also, if private data is to be maintained in this manner the key should be a java.lang.Object whose reference is not divulged to untrusted code.

      参数:
        `key` - the key used to lookup the value
      返回:
        a value previously stored using putThreadLocal.

    - #### putThreadLocal

          public final void putThreadLocal(java.lang.Object key,
                                           java.lang.Object value)

      Put a value that can later be retrieved using a given key.

      参数:
        `key` - the key used to index the value
        `value` - the value to save

    - #### removeThreadLocal

          public final void removeThreadLocal(java.lang.Object key)

      Remove values from thread-local storage.
      参数:
        `key` - the key for the entry to remove.
      从以下版本开始:
        1.5 release 2

    - #### setCachingEnabled

          @Deprecated
          public static void setCachingEnabled(boolean cachingEnabled)

      已过时。
      另请参阅:
        `ClassCache.get(Scriptable)`, `ClassCache.setCachingEnabled(boolean)`

    - #### setWrapFactory

          public final void setWrapFactory(org.mozilla.javascript.WrapFactory wrapFactory)

      Set a WrapFactory for this Context.

      The WrapFactory allows custom object wrapping behavior for Java object manipulated with JavaScript.

      从以下版本开始:
        1.5 Release 4
      另请参阅:
        `WrapFactory`

    - #### getWrapFactory

          public final org.mozilla.javascript.WrapFactory getWrapFactory()

      Return the current WrapFactory, or null if none is defined.
      从以下版本开始:
        1.5 Release 4
      另请参阅:
        `WrapFactory`

    - #### getDebugger

          public final org.mozilla.javascript.debug.Debugger getDebugger()

      Return the current debugger.
      返回:
        the debugger, or null if none is attached.

    - #### getDebuggerContextData

          public final java.lang.Object getDebuggerContextData()

      Return the debugger context data associated with current context.
      返回:
        the debugger data, or null if debugger is not attached

    - #### setDebugger

          public final void setDebugger(org.mozilla.javascript.debug.Debugger debugger,
                                        java.lang.Object contextData)

      Set the associated debugger.
      参数:
        `debugger` - the debugger to be used on callbacks from the engine.
        `contextData` - arbitrary object that debugger can use to store per Context data.

    - #### getDebuggableView

          public static org.mozilla.javascript.debug.DebuggableScript getDebuggableView(org.mozilla.javascript.Script script)

      Return DebuggableScript instance if any associated with the script. If callable supports DebuggableScript implementation, the method returns it. Otherwise null is returned.

    - #### hasFeature

          public boolean hasFeature(int featureIndex)

      Controls certain aspects of script semantics. Should be overwritten to alter default behavior.

      The default implementation calls `ContextFactory.hasFeature(Context cx, int featureIndex)` that allows to customize Context behavior without introducing Context subclasses. `ContextFactory` documentation gives an example of hasFeature implementation.

      参数:
        `featureIndex` - feature index to check
      返回:
        true if the `featureIndex` feature is turned on
      另请参阅:
        `FEATURE_NON_ECMA_GET_YEAR`, `FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME`, `FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER`, `FEATURE_TO_STRING_AS_SOURCE`, `FEATURE_PARENT_PROTO_PROPRTIES`, `FEATURE_E4X`, `FEATURE_DYNAMIC_SCOPE`, `FEATURE_STRICT_VARS`, `FEATURE_STRICT_EVAL`, `FEATURE_LOCATION_INFORMATION_IN_ERROR`, `FEATURE_STRICT_MODE`, `FEATURE_WARNING_AS_ERROR`, `FEATURE_ENHANCED_JAVA_ACCESS`

    - #### getE4xImplementationFactory

          public org.mozilla.javascript.xml.XMLLib.Factory getE4xImplementationFactory()

      Returns an object which specifies an E4X implementation to use within this `Context`. Note that the XMLLib.Factory interface should be considered experimental. The default implementation uses the implementation provided by this `Context`'s `ContextFactory`.
      返回:
        An XMLLib.Factory. Should not return `null` if `FEATURE_E4X` is enabled. See `hasFeature(int)`.

    - #### getInstructionObserverThreshold

          public final int getInstructionObserverThreshold()

      Get threshold of executed instructions counter that triggers call to `observeInstructionCount()`. When the threshold is zero, instruction counting is disabled, otherwise each time the run-time executes at least the threshold value of script instructions, `observeInstructionCount()` will be called.

    - #### setInstructionObserverThreshold

          public final void setInstructionObserverThreshold(int threshold)

      Set threshold of executed instructions counter that triggers call to `observeInstructionCount()`. When the threshold is zero, instruction counting is disabled, otherwise each time the run-time executes at least the threshold value of script instructions, `observeInstructionCount()` will be called.

      Note that the meaning of "instruction" is not guaranteed to be consistent between compiled and interpretive modes: executing a given script or function in the different modes will result in different instruction counts against the threshold. `setGenerateObserverCount(boolean)` is called with true if `threshold` is greater than zero, false otherwise.
      参数:
        `threshold` - The instruction threshold

    - #### setGenerateObserverCount

          public void setGenerateObserverCount(boolean generateObserverCount)

      Turn on or off generation of code with callbacks to track the count of executed instructions. Currently only affects JVM byte code generation: this slows down the generated code, but code generated without the callbacks will not be counted toward instruction thresholds. Rhino's interpretive mode does instruction counting without inserting callbacks, so there is no requirement to compile code differently.
      参数:
        `generateObserverCount` - if true, generated code will contain calls to accumulate an estimate of the instructions executed.

    - #### createClassLoader

          public org.mozilla.javascript.GeneratedClassLoader createClassLoader(java.lang.ClassLoader parent)

      Create class loader for generated classes. The method calls `ContextFactory.createClassLoader(ClassLoader)` using the result of `getFactory()`.

    - #### getApplicationClassLoader

          public final java.lang.ClassLoader getApplicationClassLoader()

    - #### setApplicationClassLoader

          public final void setApplicationClassLoader(java.lang.ClassLoader loader)

    - #### isDebugModel

          public boolean isDebugModel()

    - #### isGeneratingDebugChanged

          public final boolean isGeneratingDebugChanged()

    - #### addActivationName

          public void addActivationName(java.lang.String name)

      Add a name to the list of names forcing the creation of real activation objects for functions.
      参数:
        `name` - the name of the object to add to the list

    - #### isActivationNeeded

          public final boolean isActivationNeeded(java.lang.String name)

      Check whether the name is in the list of names of objects forcing the creation of activation objects.
      参数:
        `name` - the name of the object to test
      返回:
        true if an function activation object is needed.

    - #### removeActivationName

          public void removeActivationName(java.lang.String name)

      Remove a name from the list of names forcing the creation of real activation objects for functions.
      参数:
        `name` - the name of the object to remove from the list