The Mozilla
Organization
At A Glance
Feedback
Get Involved
Newsgroups
License Terms
Newsbot
Developer Docs
Roadmap
Projects
Ports
Module Owners
Hacking
Get the Source
Build It
Testing
Download
Bugzilla
Bug Writing
Tools
View Source
Tree Status
New Checkins
Submit A Bug
FAQ
Search

Rhino: JavaScriptTM for JavaTM


What is Rhino?

Rhino is an implementation of JavaScript written entirely in Java. It gets its name from the animal on the cover of the O'Reilly book about JavaScript.

Binaries

You can download binaries (JAR files) from ftp://ftp.mozilla.org/pub/js/. Rhino 1.4 Release 3 is a the last qualified release. The current Rhino tip reflects the latest checkins and bug fixes, but has not been fully qualified. The differences between the two are reflected in the change log.

Source

The source code for Rhino is available under the NPL and can be found in the CVS tree at mozilla/js/rhino. It can also be viewed using LXR at http://lxr.mozilla.org/mozilla/source/js/rhino/. Finally, the zip files available with binaries from the ftp site also contain source.

Documentation

  • Overview - An overview of the JavaScript language and of Rhino.
  • Requirements and Limitations - What you must have to run Rhino; what Rhino cannot do.
  • Getting Started - How to get started using the Rhino engine.
  • Embedding tutorial - A short tutorial on how to embed Rhino into your application.
  • API Reference - An annotated outline of the programming interface to Rhino (tip only).
  • Examples - A set of examples showing how to control the JavaScript engine and build JavaScript host objects.
  • Tools for developing JavaScript scripts.
  • Performance Hints - Some tips on writing faster JavaScript code.
  • Optimization - Details on the various optimization levels.
  • Runtime - A brief description of the JavaScript runtime.
  • Small Footprint - Hints for those interested in small-footprint embeddings.
  • Recent Changes - Describes recent changes to Rhino

News

Some recent items of note. You also might want to look over the netscape.public.mozilla.jseng newsgroup, which has information about both the C and Java implementations of JavaScript.

6/16/99
The JavaOne session on Rhino was well attended. Check out the followup.

6/3/99
Frank Mitchell has implemented much of LC3. The biggest benefit of this is a better algorithm for selecting overloaded methods from Java objects.

5/27/99
The ICE browser announces that it's moving to embrace Rhino. See ICE browser 4.06 with ECMAScript.

5/5/99
Rhino released to mozilla.org.

4/22/99
If you're headed to JavaOne, check out the talk "JavaScript for the Java Platform" that will be all about Rhino and its uses. Here's the short abstract:

JavaScriptTM for the JavaTM platform is an implementation of the JavaScript scripting language that is a standard for web scripting. It is written entirely in the JavaTM programming language and has been licensed by Sun for use with the JavaTM 2 platform. The engine supports on-the-fly compilation to Java programming language bytecodes, providing good execution speed, plus it is fully compatible with the ECMA/ISO standard for ECMAScript. Learn how to use its APIs to add scripting to your applications, or just see how easy it is to script Java programming language classes for testing and exploratory programming.

History

The Rhino project was started at Netscape in Fall 1997. At the time, Netscape was planning to produce a version of Navigator written entirely in Java and so it needed an implementation of JavaScript written in Java. When Netscape stopped work on "Javagator", as it was called, somehow Rhino escaped the axe (rumor had it that the executives "forgot" it existed). Since then, a couple of major companies (including Sun) have licensed Rhino for use in their products and paid Netscape to do so, allowing us to continue work on it. Now Rhino is planned to be part of several server products from Netscape as well.

Originally, Rhino compiled all JavaScript code to Java bytecodes in generated classfiles. This produced the best performance (often beating the C implementation of JavaScript when run on a JIT), but suffered from two faults. First, compilation time was long since generating Java bytecodes and loading the generated classes was a heavyweight process. Also, the implementation effectively leaked memory since most JVMs don't really collect unused classes or the strings that are interned as a result of loading a class file.

So in Fall of 1998, Rhino added an interpretive mode. The classfile generation code was moved to an optional, dynamically-loaded package. Compilation is faster and when scripts are no longer in use they can be collected like any other Java object.

Originally Rhino classfile generation had been held back from release. However the licensees of Rhino have now agreed to release all of Rhino to open source, including class file generation.
 

Wish List

We'll continue to evolve Rhino to match the JavaScript language as it changes. If you'd like to contribute bug fixes from your use of Rhino, or even help grow the beast, we'd love your input. Here are a few items on our wish list that we haven't been able to do yet.
  • The JavaScript debugger currently works on generated class files, but not the interpreter mode that is distributed on mozilla.org. It shouldn't be too hard to get the debugger working on the interpreter using the current implementation as a guide. Some documentation is available here.
  • A long time ago an implementation of communication between CORBA objects and Rhino was implemented. (We called it CORBAConnect, which perhaps explains why we're in engineering rather than marketing.) If this interests you and you'd like to revive it, let  know and I'll set you up with the old source we have.
  • LXR, the HTML source cross-reference borrowed from Linux, doesn't know about JavaScript. It would be nice to have support at least equal to what Java has.
  • Bugzilla tracks open bugs against Rhino and the C JavaScript engine. (Bugs against Rhino are usually prefixed by "rhino") Please feel free to take a look...

Rhino image courtesy of Paul Houle.
Copyright © 1998-1999 The Mozilla Organization.
Last modified September 28, 1999.