Propagate formatting changes from the mozilla-org CVS repository

This commit is contained in:
nboyd%atg.com 2006-11-13 21:03:34 +00:00
Родитель b90cc75520
Коммит 51f645080a
9 изменённых файлов: 538 добавлений и 419 удалений

Просмотреть файл

@ -32,44 +32,47 @@
-
- ***** END LICENSE BLOCK ***** -->
<!DOCTYPE doctype PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta name="generator" content=
"HTML Tidy for Cygwin (vers 1st September 2004), see www.w3.org">
<meta http-equiv="Content-Type" content=
"text/html; charset=us-ascii">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="en">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta name="Author" content="Igor Bukanov">
<meta name="KeyWords" content="Rhino, JavaScript, Java">
<title>Change Log</title>
<style type="text/css">
P { text-align: justify; }
</style>
<link rel="up" href="./" title="Rhino project page">
</head>
<body bgcolor="#FFFFFF">
<h1 align="center">Change Log for Rhino</h1>
<body>
<p class="crumbs"><em>You are here:</em> <a href="./">Rhino project page</a> &gt; <strong>Change Log</strong></p>
<h1 style="text-align: center;">Change Log for Rhino</h1>
<h2>Change logs for previous Rhino releases</h2>
<ul>
<li><a href="rhino16R2.html">Rhino 1.6R2</a>, released
<li><a href="rhino16R2.html">Rhino 1.6R2</a>, released
2005-09-19</li>
<li><a href="rhino16R1.html">Rhino 1.6R1</a>, released
<li><a href="rhino16R1.html">Rhino 1.6R1</a>, released
2004-11-29</li>
<li><a href="rhino15R5.html">Rhino 1.5R5</a>, released
<li><a href="rhino15R5.html">Rhino 1.5R5</a>, released
2004-03-25</li>
<li><a href="rhino15R41.html">Rhino 1.5R4.1</a>, released
<li><a href="rhino15R41.html">Rhino 1.5R4.1</a>, released
2003-04-21</li>
<li><a href="rhino15R4.html">Rhino 1.5R4</a>, released
<li><a href="rhino15R4.html">Rhino 1.5R4</a>, released
2003-02-10</li>
<li><a href="rhino15R3.html">Rhino 1.5R3</a>, released
<li><a href="rhino15R3.html">Rhino 1.5R3</a>, released
2002-01-27</li>
<li><a href="rhino15R2.html">Rhino 1.5R2</a>, released
<li><a href="rhino15R2.html">Rhino 1.5R2</a>, released
2001-07-27</li>
<li><a href="rhino15R1.html">Rhino 1.5R1</a>, released
<li><a href="rhino15R1.html">Rhino 1.5R1</a>, released
2000-09-10</li>
</ul>
<hr width="100%">
<br>
<a href="index.html">back to top</a>
</body>
</html>

Просмотреть файл

@ -32,24 +32,40 @@
-
- ***** END LICENSE BLOCK ***** -->
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="en">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta name="Author" content="Norris Boyd">
<meta name="KeyWords" content="Rhino, JavaScript, Java">
<title>Rhino Documentation</title>
</head>
<style>
h1 { text-align: center }
th { text-align: left; font-weight: normal; width: 220px }
hr { width: 100% }
<link rel="up" href="./" title="Rhino project page">
<link rel="section" href="#general" title="General">
<link rel="section" href="#scripts" title="Writing Scripts">
<link rel="section" href="#javaScript" title="JavaScript Tools">
<link rel="section" href="#embedding" title="Embedding Rhino">
<style type="text/css">
h1 { text-align: center; }
th { text-align: left; font-weight: normal; width: 220px; }
</style>
</head>
<body>
<p class="crumbs"><em>You are here:</em> <a href="./">Rhino project page</a> &gt; <strong>Rhino Documentation</strong></p>
<h1> Rhino Documentation</h1>
<h3>General</h3>
<h2><a name="general" id="general">General</a></h2>
<table>
<tbody>
<tr>
@ -73,13 +89,13 @@ hr { width: 100% }
<td>Answers to frequently asked questions about Rhino.</td>
</tr>
<tr>
<th><a href="http://www.ociweb.com/jnb/archive/jnbMar2001.html">Scripting Languages for Java</a></th>
<th><a class="ex-ref" href="http://www.ociweb.com/jnb/archive/jnbMar2001.html">Scripting Languages for Java</a></th>
<td>An article comparing and contrasting Rhino and Jython.</td>
</tr>
</tbody>
</table>
<h3>Writing Scripts</h3>
<h2><a name="scripts" id="scripts">Writing Scripts</a></h2>
<table>
<tbody>
<tr>
@ -97,7 +113,7 @@ hr { width: 100% }
</tbody>
</table>
<h3>JavaScript Tools</h3>
<h2><a name="javascript" id="javascript">JavaScript Tools</a></h2>
<table>
<tbody>
<tr>
@ -113,13 +129,13 @@ hr { width: 100% }
<td>Compiling scripts into Java class files.</td>
</tr>
<tr>
<th><a href="http://www.mozilla.org/js/tests/library.html">Testing</a></th>
<th><a href="../js/tests/library.html">Testing</a></th>
<td>Running the JavaScript test suite.</td>
</tr>
</tbody>
</table>
<h3>Embedding Rhino</h3>
<h2><a name="embedding" id="embedding">Embedding Rhino</a></h2>
<table>
<tbody>
<tr>
@ -127,13 +143,14 @@ hr { width: 100% }
<td>A short tutorial on how to embed Rhino into your application.</td>
</tr>
<tr>
<th><a href="apidocs/index.html">API javadoc Reference</a></th>
<td>An annotated outline of the programming interface to Rhino (tip only).</td>
<th><a href="apidocs/">API javadoc Reference</a></th>
<td>An annotated outline of the programming interface to Rhino
(tip only).</td>
</tr>
<tr>
<th><a href="scopes.html">Scopes and Contexts</a></th>
<td>Describes how to use scopes and contexts for the best performance
and flexibility, with an eye toward multithreaded environments.</td>
and flexibility, with an eye toward multithreaded environments.</td>
</tr>
<tr>
<th><a href="serialization.html">Serialization</a></th>
@ -153,13 +170,13 @@ and flexibility, with an eye toward multithreaded environments.</td>
build JavaScript host objects.</td>
</tr>
<tr>
<th><a href="bsf.html">Using Rhino with BSF</a></th>
<td>How to use Rhino with apps that support BSF (Bean Scripting Framework) from the Apache Jakarta project.</td>
<th><a href="bsf.html">Using Rhino with
<abbr title="Bean Scripting Framework">BSF</abbr></a></th>
<td>How to use Rhino with apps that support
<dfn>BSF (Bean Scripting Framework)</dfn> from the Apache Jakarta project.</td>
</tr>
</tbody>
</table>
<h3><hr><a href="index.html">back to top</a></h3>
</body>
</html>

Просмотреть файл

@ -32,41 +32,58 @@
-
- ***** END LICENSE BLOCK ***** -->
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="en">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta name="Author" content="Igor Bukanov">
<meta name="KeyWords" content="Rhino, JavaScript, Java">
<title>Rhino Downloads</title>
<link rel="up" href="./" title="Rhino project page">
<link rel="section" href="#binaries" title="Rhino Binaries">
<link rel="section" href="#source" title="Getting source code for Rhino">
</head>
<body>
<center><b><font size="+3">Rhino Downloads</font></b></center>
<p class="crumbs"><em>You are here:</em> <a href="./">Rhino project page</a> &gt; <strong>Rhino Downloads</strong></p>
<h1>Rhino Downloads</h1>
<p>Rhino is available for download both in source and compiled form. </p>
<h3> Binaries</h3>
<h2><a name="binaries" id="binaries">Binaries</a></h2>
<p>
You can download binary distributions of Rhino from <a
href="ftp://ftp.mozilla.org/pub/mozilla.org/js/"> ftp://ftp.mozilla.org/pub/mozilla.org/js/</a>
. These zip files includes precompiled <tt>js.jar</tt> with all Rhino classes, documentation, examples and sources.
href="ftp://ftp.mozilla.org/pub/mozilla.org/js/">ftp://ftp.mozilla.org/pub/mozilla.org/js/</a>
. These zip files includes precompiled <code class="filename">js.jar</code>
with all Rhino classes, documentation, examples and sources.
</p>
<p>
Rhino 1.6R4 is the last qualified release. It includes support for <a
href="http://www.ecma-international.org/publications/standards/Ecma-357.htm">ECMAScript for XML</a> (E4X). To implement E4X runtime Rhino uses <a
href="http://xmlbeans.apache.org/">XMLBeans</a> library and if you would like to use E4X you need to add <tt>xbean.jar</tt> from XMLBeans distribution to your class path.</p>
Rhino 1.6R4 is the last qualified release. It includes support for
<a class="ex-ref"
href="http://www.ecma-international.org/publications/standards/Ecma-357.htm">ECMAScript for XML</a> (E4X). To implement E4X runtime Rhino uses <a class="ex-ref"
href="http://xmlbeans.apache.org/">XMLBeans</a> library and if you
would like to use E4X you need to add <code class="filename">xbean.jar</code>
from XMLBeans distribution to your class path.</p>
<table border=1 cellpadding=2 cellspacing=0>
<table class="data">
<thead>
<tr>
<th>Release</th>
<th>Release Date</th>
<th>Change log</th>
<th>Download link</th>
<th scope="col">Release</th>
<th scope="col">Release Date</th>
<th scope="col">Change log</th>
<th scope="col">Download link</th>
</tr>
</thead>
<tbody>
<tbody>
<tr>
<td>Rhino 1.6R4</td>
<td>2006-09-10</td>
@ -144,30 +161,35 @@ href="http://xmlbeans.apache.org/">XMLBeans</a> library and if you would like to
<td><a href="ftp://ftp.mozilla.org/pub/mozilla.org/js/older-packages/rhino14R3.zip">rhino14R3.zip</a></td>
</tr>
</tbody>
</table>
<p>If you are looking for <tt>js.jar</tt> for XSLT or for IBM's Bean
Scripting Framework (BSF), please read the following <a href="bsf.html#bsf-issue">note</a> and then download one of the zip files above and unzip it. </p>
<p>If you are looking for <code class="filename">js.jar</code> for XSLT
or for IBM's <dfn>Bean Scripting Framework (BSF)</dfn>, please read the
following <a href="bsf.html#bsf-issue">note</a> and then download one of
the zip files above and unzip it.</p>
<h3> Source</h3>
The source code for Rhino is available under a dual <a
href="http://www.mozilla.org/MPL/MPL-1.1.html">MPL 1.1</a>/GPL 2.0 license. In addition to getting the
source from the zip files above, the source code for Rhino can be found in the
CVS tree at mozilla/js/rhino. See <a
href="http://www.mozilla.org/cvs.html">source code via cvs</a> for details on
how to set up CVS, define your CVSROOT, and login. Once you've done that, just
execute the command
<pre>&nbsp;&nbsp;&nbsp; cvs co mozilla/js/rhino</pre>
to get the tip source.
<h2><a name="source" id="source">Source</a></h2>
<p>The source code for Rhino is available under <a
href="http://www.mozilla.org/MPL/MPL-1.1.html">MPL 1.1</a>/GPL 2.0 license. In addition to
getting the source from the zip files above, the source code for
Rhino can be found in the CVS tree at mozilla/js/rhino. See <a
href="http://developer.mozilla.org/en/docs/Mozilla_Source_Code_Via_CVS">source code via cvs</a> for details on how to set up CVS, define your CVSROOT, and login. Once
you've done that, just execute the command</p>
<pre class="code">&nbsp;&nbsp;&nbsp; cvs co mozilla/js/rhino
</pre>
<p>to get the tip source.</p>
<p>The current tip can also be viewed using LXR at <a
href="http://lxr.mozilla.org/mozilla/source/js/rhino/">
http://lxr.mozilla.org/mozilla/source/js/rhino/</a> . See also <a href="changes.html">change log</a> for the current tip.</p>
http://lxr.mozilla.org/mozilla/source/js/rhino/</a> . See also
<a href="changes.html">change log</a> for the current tip.</p>
<p>
Rhino uses <a href="http://ant.apache.org/">Ant</a> as its build system and running <tt>ant</tt> command at the top directory of Rhino distribution should print the list of available build targets.
</p>
<hr width="100%"><a href="index.html">back to top</a> <br>
&nbsp; <br>
Rhino uses <a class="ex-ref" href="http://ant.apache.org/">Ant</a> as its
build system and running <tt>ant</tt> command at the top
directory of Rhino distribution should print the list of
available build targets.</p>
</body>
</html>

Просмотреть файл

@ -32,55 +32,55 @@
-
- ***** END LICENSE BLOCK ***** -->
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="en">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta name="Author" content="Norris Boyd">
<meta name="GENERATOR" content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]">
<meta name="KeyWords" content="Rhino, JavaScript, Java">
<title>Rhino FAQ</title>
<link rel="up" href="./" title="Rhino project page">
</head>
<body bgcolor="#FFFFFF">
<script src="owner.js"></script>
<body>
<script type="text/javascript" src="owner.js"></script>
<center>
<h1>
Frequently Asked Questions about Rhino</h1></center>
<script>document.write(owner());</script>
<p class="crumbs"><em>You are here:</em> <a href="./">Rhino project page</a> &gt;
<strong>Rhino FAQ</strong></p>
<br><script>
var d = new Date(document.lastModified);
document.write((d.getMonth()+1)+"/"+d.getDate()+"/"+d.getFullYear());
document.write('<br>');
</script>
<h1 style="text-align: center;">Frequently Asked Questions about Rhino</h1>
<script type="text/javascript">document.write(owner());</script>
<center>
<hr WIDTH="100%"></center>
<dl>
<p><b><font size=+2>Q</font>.</b> <i>How do I create a Java array from
JavaScript?</i>
<p><b><font size=+2>A.</font></b> You must use Java reflection. For instance,
to create an array of java.lang.String of length five, do
<blockquote><tt>var stringArray = java.lang.reflect.Array.newInstance(java.lang.String,
5);</tt></blockquote>
Then if you wish to assign the string "hi" to the first element, simply
execute <tt>stringArray[0] = "hi"</tt>.
<dt>How do I create a Java array from JavaScript?</dt>
<dd>You must use Java reflection. For instance, to create an array
of java.lang.String of length five, do
<pre class="code">
var stringArray = java.lang.reflect.Array.newInstance(java.lang.String, 5);
</pre>
<p>Then if you wish to assign the string "hi" to the first element, simply
execute <var>stringArray[0] = "hi"</var>.</p>
<p>Creating arrays of primitive types is slightly different: you must use
the TYPE field. For example, creating an array of seven ints can be done
with the code
<blockquote><tt>var intArray = java.lang.reflect.Array.newInstance(java.lang.Integer.TYPE,
7);</tt></blockquote>
with the code</p>
<pre class="code">
var intArray = java.lang.reflect.Array.newInstance(java.lang.Integer.TYPE, 7);
</pre><br><br></dd>
<p><br><b><font size=+2>Q</font>.</b> <i>When I try to execute a script
I get the exception </i><tt>Required security context missing</tt><i>.
What's going on?</i>
<p><b><font size=+2>A.</font></b> You've likely missed placing the <tt>Security.properties</tt>
file in your class path at <tt>org.mozilla.javascript.resources</tt>.
<h3>
<dt>When I try to execute a script I get the exception <code>Required security context missing</code>. What's going on?</dt>
<dd>You've likely missed placing the
<code class="filename">Security.properties</code> file in your class path at
<code class="filename">org.mozilla.javascript.resources</code>.</dd>
<hr WIDTH="100%"><br>
<a href="index.html">back to top</a></h3>
</dl>
</body>
</html>

Просмотреть файл

@ -32,25 +32,37 @@
-
- ***** END LICENSE BLOCK ***** -->
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="en">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title>Help with Rhino</title>
<script src="owner.js"></script>
<style>
h1 { text-align: center }
<script type="text/javascript" src="owner.js"></script>
<style type="text/css">
h1 { text-align: center; }
</style>
<link rel="up" href="./" title="Rhino project page">
<link rel="section" href="#newsgroups" title="Newsgroup and Mail Gateway">
</head>
<body>
<p class="crumbs"><em>You are here:</em> <a href="./">Rhino project page</a> &gt; <strong>Help with Rhino</strong></p>
<h1>Help with Rhino</h1>
<p>Have a question that you can't find answer to in the <a href="doc.html">documentation</a>?
Here are some additional resources for help:
</p>
<h3>Newsgroup and Mail Gateway</h3>
<h2><a name="newsgroups" id="newsgroups">Newsgroup and Mail Gateway</a></h2>
<p>
The <a href="news:netscape.public.mozilla.jseng">netscape.public.mozilla.jseng</a>
newsgroup answers questions about both Rhino and the C implementation of
@ -60,26 +72,22 @@ To post messages, send mail to <a href="mailto:mozilla-jseng@mozilla.org">mozill
To unsubscribe, mail with "unsubscribe" in the subject to <a href="mailto:mozilla-jseng-request@mozilla.org?subject=unsubscribe">mozilla-jseng-request@mozilla.org</a>.
</p>
<p>
To view archived messages, try <a href="http://groups.google.com/groups?q=netscape.public.mozilla.jseng&hl=en&lr=&safe=off&site=groups">Google groups</a> or
To view archived messages, try <a href="http://groups.google.com/groups?q=netscape.public.mozilla.jseng&amp;hl=en&amp;lr=&amp;safe=off&amp;site=groups">Google groups</a> or
other newsgroup services.
</p>
<h3>Bug System</h3>
<h2>Bug System</h2>
<p>
Use <a href="http://bugzilla.mozilla.org/enter_bug.cgi?product=Rhino">Bugzilla</a>
Use <a href="https://bugzilla.mozilla.org/enter_bug.cgi?product=Rhino">Bugzilla</a>
to enter bugs against Rhino. Note that Rhino has its own product category.
</p>
<h3>Module Owner</h3>
<h2>Module Owner</h2>
<p>
The module owner,&nbsp;<script>document.write(owner());</script>, can
The module owner,&nbsp;<script type="text/javascript">document.write(owner());</script>, can
be mailed for help as well, although he may copy his response to the newsgroup
to help others.
</p>
<p>
<hr WIDTH="100%"><a href="index.html">back to top</a>
<br>&nbsp;
<br>&nbsp;
</body>
</html>

Просмотреть файл

@ -32,89 +32,105 @@
-
- ***** END LICENSE BLOCK ***** -->
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="en">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta name="Author" content="Norris Boyd">
<meta name="GENERATOR" content="Mozilla/4.72 [en]C-NSCP (WinNT; U) [Netscape]">
<title>JavaScript Requirements and Limitations</title>
<link rel="up" href="./" title="Rhino project page">
<link rel="section" href="#requirements" title="Requirements">
<link rel="section" href="#limitations" title="Limitations">
<link rel="section" href="#platforms" title="Platforms and JITs">
<link rel="section" href="#liveconnect" title="LiveConnect">
<link rel="section" href="#jsobject" title="JSObject">
</head>
<body bgcolor="#FFFFFF">
<center>
<h1>
Requirements and Limitations</h1></center>
<body>
<h2>
<b>Requirements</b></h2>
Rhino requires version 1.1 or greater of Java.
<p class="crumbs"><em>You are here:</em> <a href="./">Rhino project page</a> &gt; <strong>JavaScript Requirements and Limitations</strong></p>
<h1 style="text-align: center;">Requirements and Limitations</h1>
<h2><a name="requirements" id="requirements">Requirements</a></h2>
<p>Rhino requires version 1.1 or greater of Java.</p>
<p>To use the JavaAdapter feature or an optimization level of 0 or greater,
Rhino must be running under a security manager that allows the definition
of class loaders.
<p>
<hr WIDTH="100%">
<h2>
<b>Limitations</b></h2>
of class loaders.</p>
<h3>
<b>Platforms and </b>JITs</h3>
Many platforms and JREs have problems converting decimal numbers to and
<h2><a name="limitations" id="limitations">Limitations</a></h2>
<h3><a name="platforms" id="platforms">Platforms and JITs</a></h3>
<p>Many platforms and JREs have problems converting decimal numbers to and
from strings. These errors are usually boundary case errors and will show
up as test failures in section 7.7.3.
up as test failures in section 7.7.3.</p>
<p>Windows versions of the Symantec JIT prior to 3.00.029(i) will report
internal errors for some generated class files.
internal errors for some generated class files.</p>
<p>On the Symantec JIT and the AIX JVM, accessing a static field of a class
that has not yet loaded may not give the correct value of the field. For
example, accessing
<tt>java.io.File.separatorChar</tt> before <tt>java.io.File</tt>
has been loaded will return a value of 0. (This is a bug in the JIT; accessing
the field should cause the class to be loaded.)
<code class="filename">java.io.File.separatorChar</code> before <code class="filename">java.io.File</code>
has been loaded will return a value of 0. (This is a bug in the JIT;
accessing the field should cause the class to be loaded.)</p>
<p>The AIX Java version "JDK 1.1.6 IBM build a116-19980924 (JIT enabled:
jitc)" core dumps running several classes generated by Rhino. It also has
errors in java.lang.Math.pow that are reflected as failures in the JavaScript
Math object's pow method.
<p>IBM Java for Linux version "JDK 1.1.8 IBM build l118-19991013 (JIT enabled:
jitc)" has errors in java.lang.Math.pow that are reflected as test failures
in the JavaScript Math object's pow method.
errors in java.lang.Math.pow that are reflected as failures in the
JavaScript Math object's pow method.</p>
<p>IBM Java for Linux version "JDK 1.1.8 IBM build l118-19991013 (JIT
enabled: jitc)" has errors in java.lang.Math.pow that are reflected
as test failures in the JavaScript Math object's pow method.</p>
<p>Solaris JDK 1.1.6 has errors in java.lang.Math.atan2 that are reflected
as test failures in the JavaScript Math object's atan2 method.
<br>&nbsp;
<h3>
<b>LiveConnect</b></h3>
If a JavaObject's field's name collides with that of a method, the value
of that field is retrieved lazily, and can be counter-intuitively affected
by later assignments:
<blockquote><tt>javaObj.fieldAndMethod = 5;</tt>
<br><tt>var field = javaObj.fieldAndMethod;</tt>
<br><tt>javaObj.fieldAndMethod = 7;</tt>
<br><tt>// now, field == 7</tt></blockquote>
You can work around this by forcing the field value to be converted to
a JavaScript type when you take its value:
<blockquote><tt>javaObj.fieldAndMethod = 5;</tt>
<br><tt>var field = javaObj.fieldAndMethod + 0; // force conversion now</tt>
<br><tt>javaObj.fieldAndMethod = 7;</tt>
<br><tt>// now, field == 5</tt></blockquote>
as test failures in the JavaScript Math object's atan2 method.</p>
<h3>
<b>JSObject</b></h3>
Rhino does NOT support the <tt>netscape.javascript.JSObject</tt> class.
<br>&nbsp;
<h3>
<b>Date object</b></h3>
The JavaScript Date object depends on time facilities of the underlying
<h3><a name="liveconnect" id="liveconnect">LiveConnect</a></h3>
<p>If a JavaObject's field's name collides with that of a method, the value
of that field is retrieved lazily, and can be counter-intuitively affected
by later assignments:</p>
<pre class="code">
javaObj.fieldAndMethod = 5;
var field = javaObj.fieldAndMethod;
javaObj.fieldAndMethod = 7;
<span class="remark">// now, field == 7</span>
</pre>
<p>You can work around this by forcing the field value to be converted to
a JavaScript type when you take its value:</p>
<pre class="code">
javaObj.fieldAndMethod = 5;
var field = javaObj.fieldAndMethod + 0; <span class="remark">// force conversion now</span>
javaObj.fieldAndMethod = 7;
<span class="remark">// now, field == 5</span>
</pre>
<h3><a name="jsobject" id="jsobject">JSObject</a></h3>
<p>Rhino does <strong>NOT</strong> support the
<code class="filename">netscape.javascript.JSObject</code> class.</p>
<h3>Date object</h3>
<p>The JavaScript Date object depends on time facilities of the underlying
Java runtime to determine daylight savings time dates. Earlier JRE versions
may report a date for the daylight savings changeover that is a week off.
JRE 1.1.6 reports the correct date.
<p>Under the 1.1.6 JRE, evaluating <tt>(new Date(1998, 9, 25, 2)).toString()</tt>
returns:
<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Sun Oct 25 02:00:00 GMT-0800 (PST) 1998</pre>
Earlier versions may return:
<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Sun Oct 25 02:00:00 GMT-0700 (PDT) 1998</pre>
(the JRE doesn't report the changeover until Nov. 1.)
<p>The Microsoft SDK 3.1 for Java also exhibits this problem.
<p>
<hr WIDTH="100%">
<br><a href="#">back to top</a>
JRE 1.1.6 reports the correct date.</p>
<p>Under the 1.1.6 JRE, evaluating <code class="command">(new Date(1998, 9, 25, 2)).toString()</code>
returns:</p>
<pre class="code"> Sun Oct 25 02:00:00 GMT-0800 (PST) 1998
</pre>
<p>Earlier versions may return:</p>
<pre class="code"> Sun Oct 25 02:00:00 GMT-0700 (PDT) 1998
</pre>
<p>(the JRE doesn't report the changeover until Nov. 1.)</p>
<p>The Microsoft SDK 3.1 for Java also exhibits this problem.</p>
</body>
</html>

Просмотреть файл

@ -32,24 +32,34 @@
-
- ***** END LICENSE BLOCK ***** -->
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Author" CONTENT="Norris Boyd">
<META NAME="GENERATOR" CONTENT="Mozilla/4.05 [en] (WinNT; U) [Netscape]">
<TITLE>Optimization</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<CENTER>
<H1>
Optimization</H1></CENTER>
<html lang="en">
<H2>
Optimization settings</H2>
<P>The currently supported optimization settings are:</P>
<head>
<P><B>-1</B></P>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="en">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta name="Author" content="Norris Boyd">
<title>Optimization</title>
<link rel="up" href="./" title="Rhino project page">
</head>
<body>
<p class="crumbs"><em>You are here:</em> <a href="./">Rhino project page</a> &gt; <strong>Optimization</strong></p>
<h1 style="text-align: center;">Optimization</h1>
<h2>Optimization settings</h2>
<p>The currently supported optimization settings are:</p>
<p><b>-1</b></p>
<p>Interpretive mode is always used. The compilation time is minimized at the
expense of runtime performance. No class files are generated, which may improve
@ -58,47 +68,40 @@ is that the interpreter performs tail-call elimination of recursive functions.
Also, you must use this optimization level if your code uses Continuation
objects.
<p>
If the optimization package is not available, then optimization acts as if it is always -1.
</p>
<p>If the optimization package is not available, then optimization
acts as if it is always -1.</p>
<P><B>0</B>
<p><b>0</b></p>
<P>No optimizations are
performed. The bytecode compiler runs fastest in this mode, but the generated byte code
is less efficient.</P>
<p>No optimizations are performed. The bytecode compiler runs fastest
in this mode, but the generated byte code is less efficient.</p>
<P><B>1-9</B>
<p><b>1-9</b></p>
<P>All optimizations are performed. Simple data &amp; type
flow analysis is performed to determine which JavaScript variables can be
allocated to Java VM registers, and which variables are used only as Numbers.
Local common sub-expressions are collapsed (currently this only happens for
property lookup, but in the future more expressions may be optimized). All local
variables and parameters are allocated to Java VM registers. Function call
targets are speculatively pre-cached (based on the name used in the source) so
that dispatching can be direct, pending runtime confirmation of the actual
target. Arguments are passed as Object/Number pairs to reduce conversion
overhead.</P>
<p>All optimizations are performed. Simple data &amp; type
flow analysis is performed to determine which JavaScript variables can
be allocated to Java VM registers, and which variables are used only as
Numbers. Local common sub-expressions are collapsed (currently this only
happens for property lookup, but in the future more expressions may be
optimized). All local variables and parameters are allocated to Java VM
registers. Function call targets are speculatively pre-cached (based on
the name used in the source) so that dispatching can be direct, pending
runtime confirmation of the actual target. Arguments are passed as
Object/Number pairs to reduce conversion overhead.</p>
<P>Note:
<OL>
<LI>
Some language features (indirect calls to eval, use
of the arguments property of function objects) were previously not supported
in higher optimization levels. These features have been removed from the
language in ECMA, so higher optimization levels are now conformant.
<p>Note:</p>
<LI>
Future versions may allocate more aggressive
optimizations to higher optimization levels. For compatibility with future
versions, use level 1. For maximal optimization, use level 9, but retest
your application when upgrading to new versions.</LI>
</OL>
<ol>
<li>Some language features (indirect calls to eval, use
of the arguments property of function objects) were previously not supported
in higher optimization levels. These features have been removed from the
language in ECMA, so higher optimization levels are now conformant.</li>
<li>Future versions may allocate more aggressive
optimizations to higher optimization levels. For compatibility with future
versions, use level 1. For maximal optimization, use level 9, but retest
your application when upgrading to new versions.</li>
</ol>
<P>
<HR WIDTH="100%">
<BR><A HREF="index.html">back to top</A>
<br>
</BODY>
</HTML>
</body>
</html>

Просмотреть файл

@ -32,60 +32,75 @@
-
- ***** END LICENSE BLOCK ***** -->
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="en">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta name="Author" content="Norris Boyd">
<meta name="GENERATOR" content="Mozilla/4.72 [en]C-NSCP (WinNT; U) [Netscape]">
<title>JavaScript Overview</title>
<link rel="up" href="./" title="Rhino project page">
<link rel="section" href="#language" title="Language">
<link rel="section" href="#deprec" title="Deprecated Language Features">
<link rel="section" href="#versions" title="JavaScript Language Versions">
<link rel="section" href="#security" title="Security">
</head>
<body bgcolor="#FFFFFF">
<center>
<h1>
Rhino Overview</h1></center>
<body>
<h3>
Overview of Rhino</h3>
Most people who have used JavaScript before have done so by adding scripts
<p class="crumbs"><em>You are here:</em> <a href="./">Rhino project page</a> &gt; <strong>JavaScript Overview</strong></p>
<h1 style="text-align: center;">Rhino Overview</h1>
<h2>Overview of Rhino</h2>
<p>Most people who have used JavaScript before have done so by adding scripts
to their HTML web pages. However, Rhino is an implementation of the core
language only and doesn't contain objects or methods for manipulating HTML
documents.
<p>Rhino contains
documents.</p>
<p>Rhino contains</p>
<ul>
<li>
All the features of JavaScript 1.5</li>
<li>
Allows direct scripting of Java</li>
<li>
A JavaScript shell for executing JavaScript scripts</li>
<li>
A JavaScript compiler to transform JavaScript source files into Java class
<li>All the features of JavaScript 1.5</li>
<li>Allows direct scripting of Java</li>
<li>A JavaScript shell for executing JavaScript scripts</li>
<li>A JavaScript compiler to transform JavaScript source files into Java class
files</li>
</ul>
<h3>
Language</h3>
The JavaScript language itself is standardized by Standard ECMA-262 <i>ECMAScript:
A general purpose, cross-platform programming language</i>. Rhino 1.5 implements
JavaScript 1.5, which conforms to Edition 3 of the Standard. The Standard
may be <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">downloaded</a> or
obtained by mail from ECMA, 114 Rue du Rh&ocirc;ne, CH1204 Geneva, Switzerland.
<p>Rhino 1.6 also implements ECMA-357 <i>ECMAScript for XML (E4X)</i>. See the <a href="http://www.ecma-international.org/publications/standards/Ecma-357.htm">specification</a> for more information on the standard, and <a href="rhino16R1.html#E4X">Rhino version 1.6R1</a> for details on the implementation in Rhino.
<h2><a name="language" id="language">Language</a></h2>
<p>The JavaScript language itself is standardized by Standard ECMA-262
<i>ECMAScript: A general purpose, cross-platform programming language</i>.
Rhino 1.5 implements JavaScript 1.5, which conforms to Edition 3 of
the Standard. The Standard may be <a class="ex-ref" href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">downloaded</a>
or obtained by mail from</p>
<address>ECMA,<br>
114 Rue du Rh&ocirc;ne,<br>
CH1204 Geneva,
<br>Switzerland.</address>
<p>Rhino 1.6 also implements ECMA-357 <i>ECMAScript for XML (E4X)</i>.
See the <a class="ex-ref" href="http://www.ecma-international.org/publications/standards/Ecma-357.htm">specification</a>
for more information on the standard, and
<a href="rhino16R1.html#E4X">Rhino version 1.6R1</a> for details on
the implementation in Rhino.</p>
<p>In addition, Rhino has implemented JavaAdapters, which allows JavaScript
to implement any Java interface or extend any Java class with a JavaScript
object. See the <tt>enum.js</tt> example for more information.
<p>Numerous books and tutorials on JavaScript are available.
<br>&nbsp;
<br>&nbsp;
<h3>
Deprecated Language Features</h3>
Several language features introduced in JavaScript 1.2 are now deprecated.
object. See the <code class="filename">enum.js</code> example for more
information.</p>
<p>Numerous books and tutorials on JavaScript are available.</p>
<h3><a name="deprec" id="deprec">Deprecated Language Features</a></h3>
<p>Several language features introduced in JavaScript 1.2 are now deprecated.
These features allow "computational reflection": that is, the ability for
a script to determine and influence aspects of the way it is evaluated.
These features are generally not broadly useful, yet they impose significant
@ -93,92 +108,90 @@ constraints on implementations that hamper or prevent optimization. The
deprecated features are the <tt>__proto__</tt> and <tt>__parent__</tt>
properties, and the constructors <tt>With</tt>, <tt>Closure</tt>, and <tt>Call</tt>.
Attempts to invoke these constructors with the language version 1.4 will
result in an error. For other versions, a warning will be generated.
<br>&nbsp;
<br>&nbsp;
<h3>
Internationalization</h3>
The messages reported by the JavaScript engine are by default retrieved
from the property file <tt>org/mozilla/javascript/resources/Messages.properties</tt>.
result in an error. For other versions, a warning will be generated.</p>
<h3>Internationalization</h3>
<p>The messages reported by the JavaScript engine are by default retrieved
from the property file <code class="filename">org/mozilla/javascript/resources/Messages.properties</code>.
If other properties files with extensions corresponding to the current
locale exist, they will be used instead.
<br>&nbsp;
<br>&nbsp;
<h3>
<a NAME="versions"></a>JavaScript Language Versions</h3>
Some behavior in the JavaScript engine is dependent on the language version.
In browser embeddings, this language version is selected using the LANGUAGE
attribute of the SCRIPT tag with values such as "JavaScript1.2".
<p>Version 1.3 and greater are ECMA conformant.
<p><b>Operators <tt>==</tt> and <tt>!=</tt></b>
locale exist, they will be used instead.</p>
<h3><a name="versions" id="versions">JavaScript Language Versions</a></h3>
<p>Some behavior in the JavaScript engine is dependent on the
language version. In browser embeddings, this language version is selected
using the LANGUAGE attribute of the SCRIPT tag with values such as
"JavaScript1.2". <p>Version 1.3 and greater are ECMA conformant.</p>
<p><b>Operators <tt>==</tt> and <tt>!=</tt></b></p>
<p>Version 1.2 only uses strict equality for the == and != operators. In
version 1.3 and greater, == and != have the same meanings as ECMA. The
operators === and !== use strict equality in all versions.
<p><b>ToBoolean</b>
operators === and !== use strict equality in all versions.</p>
<p><b>ToBoolean</b></p>
<p><tt>Boolean(new Boolean(false))</tt> is false for all versions before
1.3. It is true (and thus ECMA conformant) for version 1.3 and greater.
<p><b>Array.prototype.toString and Object.prototype.toString</b>
<p>Version 1.2 only returns array or object literal notation ("[1,2,3]"
or "{a:1, b:2}" for example). In version 1.3 and greater these functions
are ECMA conformant.
<p><b>Array constructor</b>
<p><tt>Array(i)</tt> for a number argument <tt>i</tt> constructs an array
with a single element equal to <tt>i</tt> for version 1.2 only. Otherwise
the ECMA conformant version is used (an array is constructed with no elements
but with length property equal to <tt>i</tt>).
<p><b>String.prototype.substring</b>
are ECMA conformant.</p>
<p><b>Array constructor</b></p>
<p><code>Array(i)</code> for a number argument <var>i</var> constructs an
array with a single element equal to <var>i</var> for version 1.2 only.
Otherwise the ECMA conformant version is used (an array is constructed
with no elements but with length property equal to <var>i</var>).</p>
<p><b>String.prototype.substring</b></p>
<p>For version 1.2 only, the two arguments are not swapped if the first
argument is less than the second one. All other versions are ECMA compliant.
<p><b>String.prototype.split</b>
<p><b>String.prototype.split</b></p>
<p>For version 1.2 only, split performs the Perl4 special case when given
a single space character as an argument (skips leading whitespace, and
splits on whitespace). All other versions split on the space character
proper as specified by ECMA.
<br>&nbsp;
<br>&nbsp;
<h3>
Security</h3>
The security features in Rhino provide the ability to track the origin
proper as specified by ECMA.</p>
<h2><a name="security" id="security">Security</a></h2>
<p>The security features in Rhino provide the ability to track the origin
of a piece of code (and any pieces of code that it may in turn generate).
These features allow for the implementation of a traditional URL-based
security policy for JavaScript as in Netscape Navigator. Embeddings that
trust the JavaScript code they execute may ignore the security features.
trust the JavaScript code they execute may ignore the security features.</p>
<p>Embeddings that run untrusted JavaScript code must do two things to
enable the security features. First, every <tt>Context</tt> that is created
must be supplied an instance of an object that implements the <tt>SecuritySupport</tt>
interface. This will provide Rhino the support functionality it needs to
perform security-related tasks.
<p>Second, the value of the property <tt>security.requireSecurityDomain</tt>
should be changed to <tt>true</tt> in the resource bundle <tt>org.mozilla.javascript.resources.Security</tt>.
enable the security features. First, every <code>Context</code> that is
created must be supplied an instance of an object that implements the
<tt>SecuritySupport</tt> interface. This will provide Rhino the support
functionality it needs to perform security-related tasks.</p>
<p>Second, the value of the property
<code class="filename">security.requireSecurityDomain</code>
should be changed to <var>true</var> in the resource bundle <code class="filename">org.mozilla.javascript.resources.Security</code>.
The value of this property can be determined at runtime by calling the
<tt>isSecurityDomainRequired</tt>
method of <tt>Context</tt>. Setting this property to true requires that
<code>isSecurityDomainRequired</code>
method of <code>Context</code>. Setting this property to true requires that
any calls that compile or evaluate JavaScript must supply a security domain
object of any object type that will be used to identify JavaScript code.
In a typical client embedding, this object might be a string with the URL
of the server that supplied the script, or an object that contains a representation
of the signers of a piece of code for certificate-based security policies.
of the server that supplied the script, or an object that contains a
representation of the signers of a piece of code for certificate-based
security policies.</p>
<p>When JavaScript code attempts a restricted action, the security domain
can be retrieved in the following manner. The class context should be obtained
from the security manager (see <tt>java.lang.SecurityManager.getClassContext()</tt>).
can be retrieved in the following manner. The class context should be
obtained from the security manager (see <code class="command">java.lang.SecurityManager.getClassContext()</code>).
Then, the class of the code that called to request the restricted action
can be obtained by looking an appropriate index into the class context
array. If the caller is JavaScript the class obtained may be one of two
types. First, it may be the class of the interpreter if interpretive mode
is in effect. Second, it may be a generated class if classfile generation
is supported. An embedding can distinguish the two cases by calling <tt>isInterpreterClass()</tt>
in the <tt>Context</tt> class. If it is the interpreter class, call the
getInterpreterSecurityDomain() method of Context to obtain the security
domain of the currently executing interpreted script or function. Otherwise,
it must be a generated class, and an embedding can call <tt>getSecurityDomain()</tt>
in the class implementing
<tt>SecuritySupport</tt>. When the class was
is supported. An embedding can distinguish the two cases by calling
<code class="command">isInterpreterClass()</code>
in the <code class="filename">Context</code> class. If it is the
interpreter class, call the getInterpreterSecurityDomain() method of
Context to obtain the security domain of the currently executing
interpreted script or function. Otherwise, it must be a generated class,
and an embedding can call <code class="command">getSecurityDomain()</code>
in the class implementing <code>SecuritySupport</code>. When the class was
defined and loaded, the appropriate security domain was associated with
it, and can be retrieved by calling this method. Once the security domain
has been determined, an embedding can perform whatever checks are appropriate
to determine whether access should be allowed.
<p>
<hr WIDTH="100%">
<br><a href="index.html">back to top</a>
has been determined, an embedding can perform whatever checks are
appropriate to determine whether access should be allowed.</p>
</body>
</html>

Просмотреть файл

@ -32,86 +32,123 @@
-
- ***** END LICENSE BLOCK ***** -->
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Norris Boyd">
<meta name="GENERATOR" content="Mozilla/4.5 [en]C-NSCP (WinNT; I) [Netscape]">
<title>Performance Hints</title>
</head>
<body bgcolor="#FFFFFF">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="en">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta name="Author" content="Norris Boyd">
<title>Performance Hints</title>
<link rel="up" href="./" title="Rhino project page">
<link rel="section" href="#varstatements" title="Var statements">
<link rel="section" href="#arrays" title="Arrays">
<link rel="section" href="#eval" title="eval">
<link rel="section" href="#with" title="with">
</head>
<body>
<p class="crumbs"><em>You are here:</em> <a href="./">Rhino project page</a> &gt; <strong>Performance Hints</strong></p>
<h1 style="text-align: center;">Performance Hints</h1>
<h3><a name="varstatements" id="varstatements"><code>var</code> Statements</a></h3>
<p>Use <code>var</code> statements when possible. Not only is it good
programming practice, it can speed up your code by allowing the compiler
to generate special code to access the variables. For example, you could
rewrite</p>
<pre class="code">
function sum(a) {
result = 0;
for (i=0; i &lt; a.length; i++)
result += a[i];
return result;
}
</pre>
<p>as</p>
<pre class="code">
function sum(a) {
var result = 0;
for (var i=0; i &lt; a.length; i++)
result += a[i];
return result;
}
</pre>
<center>
<h1>
Performance Hints</h1></center>&nbsp;
<h3>
<tt>var</tt> Statements</h3>Use <tt>var</tt> statements when possible. Not only is it good
programming practice, it can speed up your code by allowing the compiler to
generate special code to access the variables. For example, you could rewrite
<p><tt>function sum(a) {</tt>
<br><tt>&nbsp;&nbsp;&nbsp; result = 0;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; for (i=0; i &lt;
a.length; i++)</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result += a[i];</tt>
<br><tt>&nbsp;&nbsp;&nbsp; return result;</tt>
<br><tt>}</tt>
<p>as
<p><tt>function sum(a) {</tt>
<br><tt>&nbsp;&nbsp;&nbsp; var result = 0;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; for (var i=0; i
&lt; a.length; i++)</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result += a[i];</tt>
<br><tt>&nbsp;&nbsp;&nbsp; return result;</tt>
<br><tt>}</tt>
<p>This is not equivalent code because the second version does
not modify global variables <tt>result</tt> and <tt>i</tt>. However, if you don't intend for any other function to
access these variables, then storing them globally is probably wrong anyway
(what if you called another function that had a loop like the one in <tt>sum</tt>!).
<br>&nbsp;
<h3>
Arrays</h3>Use the forms of the Array constructor that
specify a size or take a list of initial elements. For example, the code
<p><tt>var a = new Array();</tt>
<br><tt>for (var i=0; i &lt; n; i++)</tt>
<br><tt>&nbsp;&nbsp;&nbsp; a[i] = i;</tt>
<p>could be sped up by changing the constructor call to <tt>new Array(n)</tt>. A constructor call like that indicates to
the runtime that a Java array should be used for the first <i>n</i> entries of the array. Similarly,
<tt>new
Array(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;)</tt> or <tt>[&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]</tt> will cause a 3-element
Java array to be allocated to hold the contents of the JavaScript array.
<br>&nbsp;
<br>&nbsp;
<h3>
<tt>eval</tt> and <tt>new Function</tt></h3>Avoid calling <tt>eval</tt> when
possible. Calls to <tt>eval</tt> are slow because the script
being executed must be compiled. Constructing a new function object can be slow
for the same reason, while function expressions are more efficient because the
function can be compiled. For example, the code
<p><tt>function MyObject(a) {</tt>
<br><tt>&nbsp;&nbsp;&nbsp; this.s = a;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; this.toString = new
Function(&quot;return this.s&quot;);</tt>
<br><tt>}</tt>
<p>could be written more efficiently as
<p><tt>function MyObject(a) {</tt>
<br><tt>&nbsp;&nbsp;&nbsp; this.s = a;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; this.toString =
function () { return this.s }</tt>
<br><tt>}</tt>
<p>Beginning with Rhino 1.4 Release 2, code
passed to eval and new Function will be interpreted rather than compiled to
class files.
<br>&nbsp;</p>
<h3>
with</h3>Using the <tt>with</tt>
statement prevents the compiler from generating code for fast access to local
variables. You're probably better off explicitly accessing any properties of the
object.
<br>&nbsp;
<p>
<hr WIDTH="100%">
<br><a href="index.html">back to top</a>
<br>
not modify global variables <code>result</code> and <code>i</code>.
However, if you don't intend for any other function to access these
variables, then storing them globally is probably wrong anyway
(what if you called another function that had a loop like the one
in <code>sum</code>!).</p>
<h3><a name="arrays" id="arrays">Arrays</a></h3>
<p>Use the forms of the Array constructor that specify a size or
take a list of initial elements. For example, the code</p>
<pre class="code">
var a = new Array();
for (var i=0; i &lt; n; i++)
a[i] = i;
</pre>
<p>could be sped up by changing the constructor call to
<code>new Array(n)</code>. A constructor call like that indicates
to the runtime that a Java array should be used for the first
<var>n</var> entries of the array. Similarly,<br><br>
<code>new Array(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;)</code><br>
or<br>
<code>[&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]</code><br><br>
will cause a 3-element Java array to be allocated to hold the
contents of the JavaScript array.</p>
<h3><a name="eval" id="eval"><code>eval</code> and <code>new Function</code></a></h3>
<p>Avoid calling <code>eval</code> when possible. Calls to
<code>eval</code> are slow because the script being executed must
be compiled. Constructing a new function object can be slow for
the same reason, while function expressions are more efficient
because the function can be compiled. For example, the code</p>
<pre class="code">
function MyObject(a) {
this.s = a;
this.toString = new Function(&quot;return this.s&quot;);
}
</pre>
<p>could be written more efficiently as</p>
<pre class="code">
function MyObject(a) {
this.s = a;
this.toString = function () { return this.s }
}
</pre>
<p>Beginning with Rhino 1.4 Release 2, code passed to eval and
new Function will be interpreted rather than compiled to class
files.</p>
<h3><a name="with" id="with"><code>with</code></a></h3>
<p>Using the <code>with</code> statement prevents the compiler
from generating code for fast access to local variables. You're
probably better off explicitly accessing any properties of the
object.</p>
</body>
</html>