Rhino 1.6R6

Table of contents

  1. JavaScript 1.5 features
    1. JavaScript 1.5: “strict” mode with new warning messages
    2. JavaScript 1.5: Getters and Setters
    3. JavaScript 1.5: const keyword
  2. New E4X Implementation using Java 1.5 DOM
  3. Integration with Java security architecture
  4. Test Drivers
  5. Support for calling Java methods and constructors with variable argument lists
  6. Bug fixes

Rhino 1.6R6 adds several new features.

JavaScript 1.5 features

Rhino now supports the remaining JavaScript 1.5 features that hadn’t been implemented in previous Rhino versions.

JavaScript 1.5: “strict” mode with new warning messages

See JavaScript Strict mode for a description of JavaScript strict mode.

Briefly, Rhino reports warnings in strict mode for

  • assignments to undefined variables
  • references to undefined properties
  • inconsistent return statements in a function
  • duplicate parameter names
  • variables that hide parameters
  • assignment in a conditional (Note: you can suppress this warning by including an extra set of parentheses around the assignment)
  • trailing comma in object initializer (Note: this is always a full error in Rhino)
  • indirect calls to eval
  • useless expressions

To enable strict mode for the Rhino shell, add -strict to the command line. If you are using the API directly, set the Context feature FEATURE_STRICT_MODE.

It’s also possible to cause all warnings to be treated as errors. Add -fatal-warnings to the shell command line or set the Context feature FEATURE_WARNING_AS_ERROR.

See bug 378790 for nitty gritty details.

JavaScript 1.5: Getters and Setters

See Defining Getters and Setters in the JavaScript 1.5 Reference.

JavaScript 1.5: const keyword

See const in the JavaScript 1.5 Reference.

New E4X Implementation using Java 1.5 DOM

Since Rhino 1.6R1, Rhino has used the Apache XMLBeans library to support E4X. In Rhino 1.6R6 the E4X support has been rewritten to rely solely on the DOM3 APIs supported natively by Java 1.5. Pre-1.5 users can use DOM3 using Java’s endorsed standards override mechanism if they have a DOM3-capable XML parser. As of this release, the XMLBeans implementation remains the default if XMLBeans classes are found on the classpath; otherwise, the native DOM implementation is used if DOM3 is present. If neither XMLBeans nor DOM3 are present, E4X is not available.

Integration with Java security architecture

Rhino 1.6R6 adds org.mozilla.javascript.PolicySecurityController as a concrete implementation of an org.mozilla.javascript.SecurityController and the preferred way of integrating with Java security architecture. When no security controller is in use, generated classes and scripts run in the ProtectionDomain of Rhino classes. Wrapped access to system properties and creation of class loaders into AccessController.doPrivileged() to nicely play in secured environments.

Test Drivers

Rhino now comes with test drivers written in Java. These drivers can be used to test Rhino if you are making any changes to the core engine. They are designed to use the tests shared with the C-based SpiderMonkey engine in mozilla/js/tests in CVS.

See Running the Rhino tests for details on how to execute the tests using JsDriver.

Support for calling Java methods and constructors with variable argument lists

Java J2SE 5 added support for variable argument lists in constructors and methods. Rhino 1.6R6 now supports calling these methods and constructors using variable argument lists. For example,

java.lang.System.out.format("%3.1f%s\n", 1.6, "R6");

prints 1.6R6.

See bug 382457 for more details.

Bug fixes

This list shows all the bugs (and enhancements) fixed in Rhino 1.6R6.