Compare commits
2 Commits
templess_b
...
MOZILLA
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a66fb74e4e | ||
|
|
c46072a78b |
32
mozilla/js/rhino/CHANGELOG
Normal file
32
mozilla/js/rhino/CHANGELOG
Normal file
@@ -0,0 +1,32 @@
|
||||
This file version: $Id: CHANGELOG,v 1.1.1.1 2007-02-05 13:34:43 inonit%inonit.com Exp $
|
||||
|
||||
Changes since Rhino 1.6R5
|
||||
=========================
|
||||
- Added 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.
|
||||
- Added implementation of __defineGetter__ and __defineSetter__ to match
|
||||
SpiderMonkey. __lookupGetter__ and __lookupSetter__ are not
|
||||
implemented, nor are the JS get and set keywords. Also see #224334.
|
||||
- Fixed #318305: ScriptOrFnNode class reports bad end line number
|
||||
- Fixed #352319: Rhino threw a ClassCastException when a continuation captured
|
||||
from a catch() block was restarted.
|
||||
- Fixed #340561: <Function>.prototype should not be DontEnum
|
||||
- Fixed #342807: Could set line number/source file in thrown JavaScript Error
|
||||
- Fixed #350580: importPackage Ambiguous import error fix
|
||||
- Fixed #351664: Rethrown JavaScriptException's toString() returns
|
||||
"[object Error]"
|
||||
- Fixed #353300: Rhino now implements the ECMA-262 mandatory
|
||||
String.localeCompare
|
||||
- Fixed #353002: Outdated Information on BSF, Update Requested, Text Suggestion
|
||||
Enclosed
|
||||
- Fixed #358058: JavaScript debugger's text source editor allows tab key
|
||||
presses
|
||||
- Fixed #359411: LazilyLoadedCtor is not serializable
|
||||
- Fixed #360568: Make swing debugger easier to subclass and extend
|
||||
- Fixed #361574: Typo in Parser.java
|
||||
- Fixed #361616: toLocaleUpperCase/toLocaleLowerCase is not supported
|
||||
@@ -1,37 +1,39 @@
|
||||
<html>
|
||||
<!--
|
||||
- The contents of this file are subject to the Netscape Public
|
||||
- License Version 1.1 (the "License"); you may not use this file
|
||||
- except in compliance with the License. You may obtain a copy of
|
||||
- the License at http://www.mozilla.org/NPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS
|
||||
- IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
- implied. See the License for the specific language governing
|
||||
- rights and limitations under the License.
|
||||
-
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released
|
||||
- May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is Netscape
|
||||
- Communications Corporation. Portions created by Netscape are
|
||||
- Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
- Rights Reserved.
|
||||
-
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1998-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
- Norris Boyd
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the
|
||||
- terms of the GNU Public License (the "GPL"), in which case the
|
||||
- provisions of the GPL are applicable instead of those above.
|
||||
- If you wish to allow use of your version of this file only
|
||||
- under the terms of the GPL and not to allow others to use your
|
||||
- version of this file under the NPL, indicate your decision by
|
||||
- deleting the provisions above and replace them with the notice
|
||||
- and other provisions required by the GPL. If you do not delete
|
||||
- the provisions above, a recipient may use your version of this
|
||||
- file under either the NPL or the GPL.
|
||||
-->
|
||||
- Norris Boyd
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
<body>
|
||||
<h1>
|
||||
<span CLASS=LXRSHORTDESC>
|
||||
|
||||
@@ -1,22 +1,65 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is Rhino code, released May 6, 1999.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
# case the provisions of the GPL are applicable instead of those above. If
|
||||
# you wish to allow use of your version of this file only under the terms of
|
||||
# the GPL and not to allow others to use your version of this file under the
|
||||
# MPL, indicate your decision by deleting the provisions above and replacing
|
||||
# them with the notice and other provisions required by the GPL. If you do
|
||||
# not delete the provisions above, a recipient may use your version of this
|
||||
# file under either the MPL or the GPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
apiClasses=\
|
||||
src/org/mozilla/javascript/Callable.java,\
|
||||
src/org/mozilla/javascript/ClassCache.java,\
|
||||
src/org/mozilla/javascript/ClassDefinitionException.java,\
|
||||
src/org/mozilla/javascript/ClassShutter.java,\
|
||||
src/org/mozilla/javascript/CompilerEnvirons.java,\
|
||||
src/org/mozilla/javascript/Context.java,\
|
||||
src/org/mozilla/javascript/ContextListener.java,\
|
||||
src/org/mozilla/javascript/ContextAction.java,\
|
||||
src/org/mozilla/javascript/ContextFactory.java,\
|
||||
src/org/mozilla/javascript/GeneratedClassLoader.java,\
|
||||
src/org/mozilla/javascript/EcmaError.java,\
|
||||
src/org/mozilla/javascript/ErrorReporter.java,\
|
||||
src/org/mozilla/javascript/EvaluatorException.java,\
|
||||
src/org/mozilla/javascript/Function.java,\
|
||||
src/org/mozilla/javascript/FunctionObject.java,\
|
||||
src/org/mozilla/javascript/GeneratedClassLoader.java,\
|
||||
src/org/mozilla/javascript/ImporterTopLevel.java,\
|
||||
src/org/mozilla/javascript/JavaScriptException.java,\
|
||||
src/org/mozilla/javascript/PropertyException.java,\
|
||||
src/org/mozilla/javascript/RefCallable.java,\
|
||||
src/org/mozilla/javascript/RhinoException.java,\
|
||||
src/org/mozilla/javascript/Script.java,\
|
||||
src/org/mozilla/javascript/Scriptable.java,\
|
||||
src/org/mozilla/javascript/ScriptableObject.java,\
|
||||
src/org/mozilla/javascript/SecurityController.java,\
|
||||
src/org/mozilla/javascript/WrapFactory.java,\
|
||||
src/org/mozilla/javascript/WrappedException.java,\
|
||||
src/org/mozilla/javascript/Wrapper.java,\
|
||||
src/org/mozilla/javascript/Synchronizer.java,\
|
||||
src/org/mozilla/javascript/optimizer/ClassCompiler.java,\
|
||||
src/org/mozilla/javascript/debug/DebuggableScript.java,\
|
||||
src/org/mozilla/javascript/serialize/ScriptableInputStream.java,\
|
||||
src/org/mozilla/javascript/serialize/ScriptableOutputStream.java
|
||||
|
||||
64
mozilla/js/rhino/build.properties
Normal file
64
mozilla/js/rhino/build.properties
Normal file
@@ -0,0 +1,64 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is Rhino code, released
|
||||
# May 6, 1999.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Bukanov
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
# case the provisions of the GPL are applicable instead of those above. If
|
||||
# you wish to allow use of your version of this file only under the terms of
|
||||
# the GPL and not to allow others to use your version of this file under the
|
||||
# MPL, indicate your decision by deleting the provisions above and replacing
|
||||
# them with the notice and other provisions required by the GPL. If you do
|
||||
# not delete the provisions above, a recipient may use your version of this
|
||||
# file under either the MPL or the GPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
name: rhino
|
||||
Name: Rhino
|
||||
version: 1_6R6pre
|
||||
# See Context#getImplementationVersion() for format of this!
|
||||
implementation.version: Rhino 1.6 release 6 Pre ${implementation.date}
|
||||
|
||||
build.dir: build
|
||||
rhino.jar: js.jar
|
||||
small-rhino.jar: smalljs.jar
|
||||
|
||||
dist.name: rhino${version}
|
||||
dist.dir: ${build.dir}/${dist.name}
|
||||
|
||||
# compilation destionation
|
||||
classes: ${build.dir}/classes
|
||||
|
||||
# compilation settings
|
||||
debug: on
|
||||
target-jvm: 1.3
|
||||
source-level: 1.3
|
||||
|
||||
# jar generation settings
|
||||
jar-compression: true
|
||||
|
||||
# optional external packages
|
||||
xmlbeans: .
|
||||
xbean.jar: ${xmlbeans}/lib/xbean.jar
|
||||
jsr173.jar: ${xmlbeans}/lib/jsr173_1.0_api.jar
|
||||
@@ -1,4 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
|
||||
<!--
|
||||
Build file for Rhino using Ant (see http://jakarta.apache.org/ant/index.html)
|
||||
@@ -8,57 +42,65 @@ Requires Ant version 1.2 or later
|
||||
<project name="Rhino" default="help" basedir=".">
|
||||
|
||||
<target name="properties">
|
||||
<property name="name" value="rhino"/>
|
||||
<property name="Name" value="Rhino"/>
|
||||
<property name="version" value="1_5R5pre"/>
|
||||
<property name="rhino.jar" value="js.jar"/>
|
||||
<property name="small-rhino.jar" value="smalljs.jar"/>
|
||||
<!-- Allow user to override default settings from build.properties -->
|
||||
<property file="build.local.properties" />
|
||||
<tstamp>
|
||||
<!-- Specify date part of Context#getImplementationVersion() -->
|
||||
<format property="implementation.date" pattern="yyyy MM dd"/>
|
||||
</tstamp>
|
||||
<property file="build.properties"/>
|
||||
|
||||
<property name="jar-compression" value="true"/>
|
||||
<property name="debug" value="on"/>
|
||||
|
||||
<property name="build.dir" value="./build"/>
|
||||
<property name="classes" value="${build.dir}/classes"/>
|
||||
|
||||
<property name="dist.name" value="rhino${version}"/>
|
||||
<property name="dist.dir" value="${build.dir}/${dist.name}"/>
|
||||
<property name="dist.src" value="${dist.dir}/src"/>
|
||||
<property name="dist.toolsrc" value="${dist.dir}/toolsrc"/>
|
||||
<property name="dist.examples" value="${dist.dir}/examples"/>
|
||||
<property name="dist.docs" value="${dist.dir}/docs"/>
|
||||
<property name="dist.apidocs" value="${dist.docs}/apidocs"/>
|
||||
<property name="dist.file" value="rhino${version}.zip"/>
|
||||
<property name="dist.source-only-zip" value="rhino${version}-sources.zip"/>
|
||||
|
||||
<property file="apiClasses.properties"/>
|
||||
<property name="docsrc.dir" value="docs"/>
|
||||
<property name="dist.docsrc.dir" value="src/docs"/>
|
||||
<property name="xmlimplsrc-build-file"
|
||||
location="xmlimplsrc/build.xml"/>
|
||||
|
||||
<available property="xmlimplsrc-present?"
|
||||
file="${xmlimplsrc-build-file}" />
|
||||
|
||||
</target>
|
||||
|
||||
<target name="init" depends="properties">
|
||||
<mkdir dir="${build.dir}"/>
|
||||
<mkdir dir="${classes}"/>
|
||||
<mkdir dir="${dist.dir}"/>
|
||||
<mkdir dir="${dist.src}"/>
|
||||
<mkdir dir="${dist.toolsrc}"/>
|
||||
<mkdir dir="${dist.examples}"/>
|
||||
<mkdir dir="${dist.docs}"/>
|
||||
<mkdir dir="${dist.apidocs}"/>
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="init">
|
||||
<ant dir="src" target="compile"/>
|
||||
<ant dir="toolsrc" target="compile"/>
|
||||
<ant antfile="src/build.xml" target="compile"/>
|
||||
<ant antfile="toolsrc/build.xml" target="compile"/>
|
||||
<antcall target="xmlimplsrc-compile" />
|
||||
</target>
|
||||
|
||||
<target name="compile-all" depends="compile">
|
||||
<ant antfile="deprecatedsrc/build.xml" target="compile"/>
|
||||
</target>
|
||||
|
||||
<target name="copy-source" depends="init">
|
||||
<ant dir="src" target="copy-source"/>
|
||||
<ant dir="toolsrc" target="copy-source"/>
|
||||
<ant antfile="src/build.xml" target="copy-source"/>
|
||||
<ant antfile="toolsrc/build.xml" target="copy-source"/>
|
||||
<antcall target="xmlimplsrc-copy-source" />
|
||||
<ant antfile="deprecatedsrc/build.xml" target="copy-source"/>
|
||||
<copy todir="${dist.dir}" file="build.xml"/>
|
||||
<copy todir="${dist.dir}" file="build.properties"/>
|
||||
<copy todir="${dist.dir}" file="apiClasses.properties"/>
|
||||
</target>
|
||||
|
||||
<target name="jar" depends="compile">
|
||||
<target name="xmlimplsrc-compile" if="xmlimplsrc-present?">
|
||||
<echo>Calling ${xmlimplsrc-build-file}</echo>
|
||||
<!-- Ignore compilation errors under JDK less then 1.4 -->
|
||||
<property name="xmlimpl.compile.failonerror" value="no"/>
|
||||
<ant antfile="${xmlimplsrc-build-file}" target="compile"/>
|
||||
</target>
|
||||
|
||||
<target name="xmlimplsrc-copy-source" if="xmlimplsrc-present?">
|
||||
<echo>Calling ${xmlimplsrc-build-file}</echo>
|
||||
<ant antfile="${xmlimplsrc-build-file}" target="copy-source"/>
|
||||
</target>
|
||||
|
||||
<target name="jar" depends="compile-all">
|
||||
<jar jarfile="${dist.dir}/${rhino.jar}"
|
||||
basedir="${classes}"
|
||||
manifest="src/manifest"
|
||||
@@ -71,14 +113,18 @@ Requires Ant version 1.2 or later
|
||||
<jar basedir="${classes}" destfile="${dist.dir}/${small-rhino.jar}"
|
||||
compress="${jar-compression}">
|
||||
<include name="org/mozilla/javascript/*.class"/>
|
||||
<exclude name="org/mozilla/javascript/ClassNameHelper*.class"/>
|
||||
<exclude name="org/mozilla/javascript/ClassRepository*.class"/>
|
||||
<exclude name="org/mozilla/javascript/JavaAdapter*.class"/>
|
||||
<exclude name="org/mozilla/javascript/NotAFunctionException*.class"/>
|
||||
<exclude name="org/mozilla/javascript/Token.class"/>
|
||||
|
||||
<include name="org/mozilla/javascript/debug/*.class"/>
|
||||
<include name="org/mozilla/javascript/resources/*.properties"/>
|
||||
<include name="org/mozilla/javascript/xml/*.class"/>
|
||||
<include name="org/mozilla/javascript/continuations/*.class"/>
|
||||
<include name="org/mozilla/javascript/jdk13/*.class"/>
|
||||
|
||||
<!-- exclude classes that defines only int constants -->
|
||||
<exclude name="org/mozilla/javascript/Token.class"/>
|
||||
|
||||
<!-- exclude classes that uses class generation library -->
|
||||
<exclude name="org/mozilla/javascript/JavaAdapter*.class"/>
|
||||
|
||||
<include name="org/mozilla/javascript/regexp/*.class"
|
||||
unless="no-regexp"/>
|
||||
@@ -87,13 +133,13 @@ Requires Ant version 1.2 or later
|
||||
</target>
|
||||
|
||||
<target name="copy-examples" depends="init">
|
||||
<copy todir="${dist.examples}">
|
||||
<fileset dir="examples" includes="*.java,*.js,*.html" />
|
||||
<mkdir dir="${dist.dir}/examples"/>
|
||||
<copy todir="${dist.dir}/examples">
|
||||
<fileset dir="examples" includes="**/*.java,**/*.js,**/*.html" />
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="copy-misc" depends="init">
|
||||
<tstamp/>
|
||||
<filter token="datestamp" value="${TODAY}"/>
|
||||
<copy todir="${dist.dir}" filtering="yes">
|
||||
<fileset dir=".">
|
||||
@@ -108,36 +154,43 @@ Requires Ant version 1.2 or later
|
||||
</target>
|
||||
|
||||
<target name="copy-docs" depends="init">
|
||||
<echo message="copy from ${docsrc.dir}"/>
|
||||
<copy todir="${dist.docs}">
|
||||
<fileset dir="${docsrc.dir}"
|
||||
includes="**/*.html,**/*.jpg,**/*.gif" />
|
||||
<echo message="copy from docs"/>
|
||||
<mkdir dir="${dist.dir}/docs"/>
|
||||
<copy todir="${dist.dir}/docs">
|
||||
<fileset dir="docs" includes="**/*.html,**/*.jpg,**/*.gif,**/*.js" />
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="javadoc" depends="compile,copy-docs">
|
||||
<target name="javadoc" depends="copy-docs">
|
||||
<mkdir dir="${dist.dir}/docs/apidocs"/>
|
||||
<javadoc sourcefiles="${apiClasses}"
|
||||
sourcepath="src"
|
||||
destdir="${dist.apidocs}"
|
||||
overview="${dist.docs}/api.html"
|
||||
destdir="${dist.dir}/docs/apidocs"
|
||||
overview="${dist.dir}/docs/api.html"
|
||||
version="true"
|
||||
author="true"
|
||||
public="true"
|
||||
windowtitle="${Name}" />
|
||||
</target>
|
||||
|
||||
<target name="dist" depends="deepclean,jar,copy-all,javadoc">
|
||||
<delete file="${dist.file}" />
|
||||
<zip zipfile="${dist.file}"
|
||||
basedir="${build.dir}"
|
||||
includes="**"
|
||||
excludes="classes/**" />
|
||||
<zip destfile="${dist.file}">
|
||||
<fileset dir="${build.dir}" includes="${dist.name}/**"/>
|
||||
</zip>
|
||||
</target>
|
||||
|
||||
<target name="source-zip" depends="copy-source">
|
||||
<target name="source-zip" depends="copy-source,copy-examples,copy-docs">
|
||||
<delete file="${dist.source-only-zip}" />
|
||||
<zip zipfile="${dist.source-only-zip}" basedir="${build.dir}"
|
||||
includes="${dist.name}/src/**,${dist.name}/toolsrc/**,${dist.name}/build.xml,${dist.name}/apiClasses.properties"/>
|
||||
<zip destfile="${dist.source-only-zip}">
|
||||
<zipfileset prefix="${dist.name}" dir="${dist.dir}">
|
||||
<include name="*src/**"/>
|
||||
<include name="build.xml"/>
|
||||
<include name="*.properties"/>
|
||||
<include name="examples/**"/>
|
||||
<include name="docs/**"/>
|
||||
<exclude name="docs/apidocs/**"/>
|
||||
</zipfileset>
|
||||
</zip>
|
||||
</target>
|
||||
|
||||
<target name="clean" depends="properties">
|
||||
@@ -151,14 +204,51 @@ Requires Ant version 1.2 or later
|
||||
<delete quiet="true" file="${dist.file}"/>
|
||||
<delete quiet="true" file="${dist.source-only-zip}"/>
|
||||
</target>
|
||||
|
||||
|
||||
<!--
|
||||
The next two targets run the JavaScript Test Library tests. Note that these tests are quite extensive and take a long time
|
||||
to run. They are not documented in the 'help' target for now.
|
||||
-->
|
||||
|
||||
<!--
|
||||
Run the tests using JUnit. Beware that if you are using Ant from the command-line, there are some difficulties you may
|
||||
encounter setting this up correctly; see http://ant.apache.org/faq.html#delegating-classloader
|
||||
|
||||
IDEs that use Ant as the build system probably handle this fine.
|
||||
-->
|
||||
<target name="junit-all" depends="compile">
|
||||
<ant antfile="testsrc/build.xml" target="junit"/>
|
||||
</target>
|
||||
|
||||
<!--
|
||||
Run the tests using the Java port of jsdriver.pl. Note that running this port from the command-line
|
||||
may be more useful running this Ant target, as running from the command line allows configuration options,
|
||||
such as running with a non-default optimization level, or running only a subset of the tests.
|
||||
-->
|
||||
<target name="jsdriver-all" depends="compile">
|
||||
<ant antfile="testsrc/build.xml" target="jsdriver" />
|
||||
</target>
|
||||
|
||||
<!--
|
||||
Target just for development of the test code.
|
||||
-->
|
||||
<target name="_test-recompile" depends="compile">
|
||||
<ant antfile="testsrc/build.xml" target="clean" />
|
||||
<ant antfile="testsrc/build.xml" target="compile" />
|
||||
</target>
|
||||
|
||||
<target name="help" depends="properties">
|
||||
<echo>The following targets are available with this build file:
|
||||
|
||||
clean remove all compiled classes and copied property files
|
||||
|
||||
compile compile all classes and copy all property files
|
||||
compile compile classes and copy all property files
|
||||
into ${classes} directory
|
||||
excluding deprecated code
|
||||
|
||||
compile-all compile all classes and copy all property files
|
||||
into ${classes} directory
|
||||
including deprecated code
|
||||
|
||||
deepclean remove all generated files and directories
|
||||
|
||||
@@ -172,11 +262,11 @@ Requires Ant version 1.2 or later
|
||||
minimalist set of Rhino classes. See footprint.html
|
||||
from the doc directory for details.
|
||||
|
||||
javadoc generate generate Rhino API documentation
|
||||
in ${dist.apidocs}
|
||||
javadoc generate Rhino API documentation
|
||||
in ${dist.dir}/docs/apidocs
|
||||
|
||||
source-zip create ${dist.source-only-zip} with all Rhino
|
||||
source files necessary to recreate ${rhino.jar}
|
||||
source files necessary to recreate ${dist.file}
|
||||
</echo>
|
||||
</target>
|
||||
|
||||
|
||||
61
mozilla/js/rhino/deprecatedsrc/build.xml
Normal file
61
mozilla/js/rhino/deprecatedsrc/build.xml
Normal file
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
|
||||
<project name="src" default="compile" basedir="..">
|
||||
|
||||
<property file="build.properties"/>
|
||||
|
||||
<target name="compile">
|
||||
<javac srcdir="deprecatedsrc"
|
||||
destdir="${classes}"
|
||||
includes="org/**/*.java"
|
||||
deprecation="on"
|
||||
debug="${debug}"
|
||||
target="${target-jvm}"
|
||||
source="${source-level}"
|
||||
>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="copy-source">
|
||||
<mkdir dir="${dist.dir}/deprecatedsrc"/>
|
||||
<copy todir="${dist.dir}/deprecatedsrc">
|
||||
<fileset dir="deprecatedsrc"
|
||||
includes="**/*.java,**/*.properties,**/*.xml,manifest"/>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,53 @@
|
||||
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
// API class
|
||||
|
||||
package org.mozilla.javascript;
|
||||
|
||||
/**
|
||||
* @deprecated The exception is no longer thrown by Rhino runtime as
|
||||
* {@link EvaluatorException} is used instead.
|
||||
*/
|
||||
public class ClassDefinitionException extends RuntimeException
|
||||
{
|
||||
static final long serialVersionUID = -5637830967241712746L;
|
||||
|
||||
public ClassDefinitionException(String detail) {
|
||||
super(detail);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Bukanov
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
// API class
|
||||
|
||||
package org.mozilla.javascript;
|
||||
|
||||
/**
|
||||
* @deprecated The exception is no longer thrown by Rhino runtime as
|
||||
* {@link EvaluatorException} is used instead.
|
||||
*/
|
||||
public class NotAFunctionException extends RuntimeException
|
||||
{
|
||||
static final long serialVersionUID = 6461524852170711724L;
|
||||
|
||||
public NotAFunctionException() { }
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Norris Boyd
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// API class
|
||||
|
||||
package org.mozilla.javascript;
|
||||
|
||||
/**
|
||||
* @deprecated This exception is no longer thrown by Rhino runtime.
|
||||
*/
|
||||
public class PropertyException extends RuntimeException
|
||||
{
|
||||
static final long serialVersionUID = -8221564865490676219L;
|
||||
|
||||
public PropertyException(String detail) {
|
||||
super(detail);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,3 +1,37 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
|
||||
@@ -19,7 +53,7 @@
|
||||
<OL>
|
||||
|
||||
<LI><A NAME="_Toc502165109"></FONT><B><FONT FACE="Arial" COLOR="#000080">Console Window</A></LI>
|
||||
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">The debugger redirects the </FONT><FONT FACE="Arial" SIZE=2>System.out</FONT><FONT SIZE=2>, </FONT><FONT FACE="Arial" SIZE=2>System.in</FONT><FONT SIZE=2>, and </FONT><FONT FACE="Arial" SIZE=2>System.err</FONT><FONT SIZE=2> streams to an internal JavaScript console window which provides an editable command line for you to enter JavaScript code and view system output. The console window maintains a history of the commands you have entered. You may move backward and forward through the history list by pressing the Up/Down arrow keys on the keyboard.</P>
|
||||
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">The debugger redirects the </FONT><FONT FACE="Arial" SIZE=2>System.out</FONT><FONT SIZE=2>, </FONT><FONT FACE="Arial" SIZE=2>System.in</FONT><FONT SIZE=2>, and </FONT><FONT FACE="Arial" SIZE=2>System.err</FONT><FONT SIZE=2> streams to an internal Error console window which provides an editable command line for you to enter JavaScript code and view system output. The console window maintains a history of the commands you have entered. You may move backward and forward through the history list by pressing the Up/Down arrow keys on the keyboard.</P>
|
||||
<LI><A NAME="_Toc502165110"></FONT><B><FONT FACE="Arial" COLOR="#000080">Opening Scripts</A></LI>
|
||||
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">You may select the <B><I>File->Open</B></I> menu item on the menu bar to load JavaScript scripts contained in files. This action will display a file-selection dialog box prompting you for the location of a script to load. The selected file will be compiled and displayed in a new window.</P>
|
||||
</FONT><B><FONT FACE="Arial" COLOR="#000080"><LI>Running Scripts</LI>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,37 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
@@ -24,9 +58,8 @@ JavaScript evaluation engine with a Java thread, set attributes of the
|
||||
engine, and compile and evaluate scripts.</li>
|
||||
|
||||
<li>
|
||||
<a href="org/mozilla/javascript/ContextListener.html">ContextListener</a>
|
||||
- Allows embeddings to be notified of the creation, entering, exiting,
|
||||
and releasing of Contexts. </li>
|
||||
<a href="org/mozilla/javascript/ContextFactory.html">ContextFactory</a>
|
||||
- Allows embeddings to customize creation of Context instances and monitor entering and releasing of Contexts. </li>
|
||||
|
||||
<li>
|
||||
<a href="org/mozilla/javascript/Script.html">Script</a> - The result of
|
||||
@@ -53,14 +86,12 @@ by objects wrapping other objects. Provides a method for recovering the
|
||||
wrapped value.</li>
|
||||
|
||||
<li>
|
||||
<a href="org/mozilla/javascript/WrapHandler.html">WrapHandler</a> - Interface
|
||||
embedders can implement in order to control the way Java objects are wrapped
|
||||
<a href="org/mozilla/javascript/WrapFactory.html">WrapFactory</a> - Class
|
||||
embedders can extend in order to control the way Java objects are wrapped
|
||||
for use by JavaScript.</li>
|
||||
|
||||
<li>
|
||||
<a href="org/mozilla/javascript/ClassOutput.html">ClassOutput</a> - Interface
|
||||
embedders can implement in order to control the placement of generated
|
||||
class bytecodes.</li>
|
||||
<a href="org/mozilla/javascript/optimizer/ClassCompiler.html">ClassCompiler</a> - Class that provies API for compiling scripts into JVM class files.</li>
|
||||
|
||||
<li>
|
||||
<a href="org/mozilla/javascript/serialize/ScriptableOutputStream.html">ScriptableOutputStream</a> - This stream can be used to serialize JavaScript objects and functions.
|
||||
@@ -76,7 +107,7 @@ class bytecodes.</li>
|
||||
The Host Object API</h4>
|
||||
These APIs provide support for adding objects specific to a particular
|
||||
embedding of JavaScript in a host environment. Note that if you just want
|
||||
to script existing Java classes, you should just use <a href="http://developer.netscape.com/library/documentation/communicator/jsguide4/livecon.htm">LiveConnect</a>.
|
||||
to script existing Java classes, you should just use <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:LiveConnect_Overview">LiveConnect</a>. See also <a href="http://www.mozilla.org/js/liveconnect/">LiveConnect 3.0 specs</a>.
|
||||
It is also helpful to understand some of the implementation of the <a href="runtime.html">runtime</a>.
|
||||
<ul>
|
||||
<li>
|
||||
@@ -103,7 +134,7 @@ to be used as JavaScript function objects.</li>
|
||||
|
||||
<li>
|
||||
<a href="org/mozilla/javascript/ImporterTopLevel.html">ImporterTopLevel</a>
|
||||
- Allows embeddings to use the importClass and importPackage functions.</li>
|
||||
- Allows embeddings to use the JavaImporter constructor.</li>
|
||||
</ul>
|
||||
|
||||
<h4>
|
||||
@@ -111,27 +142,23 @@ Exceptions</h4>
|
||||
These exceptions are thrown by JavaScript.
|
||||
<ul>
|
||||
<li>
|
||||
<a href="org/mozilla/javascript/RhinoException.html">RhinoException</a>
|
||||
- Common root for all exception explicitly thrown by Rhino engine.</li>
|
||||
|
||||
<a href="org/mozilla/javascript/JavaScriptException.html">JavaScriptException</a>
|
||||
- Thrown from within JavaScript by the JavaScript 'throw' statement, or
|
||||
by LiveConnect calls from JavaScript into Java. Wraps a JavaScript value.</li>
|
||||
- Thrown from within JavaScript by the JavaScript 'throw' statement. It wrapps the JavaScript value from 'throw' statement.</li>
|
||||
|
||||
<li>
|
||||
<a href="org/mozilla/javascript/ClassDefinitionException.html">ClassDefinitionException</a>
|
||||
- Thrown if errors are detected while attempting to define a host object
|
||||
from a Java class.</li>
|
||||
<a href="org/mozilla/javascript/WrappedException.html">EcmaError</a>
|
||||
- Thrown by Rhino runtime when particular runtime operation a scripts tries to execute is not allowed. The exception is thrown, for example, when a script attempts to check properties of <tt>undefined</tt>or <tt>null</tt> or refer to a name that can not be found in the current scope chain.</li>
|
||||
|
||||
<li>
|
||||
<a href="org/mozilla/javascript/PropertyException.html">PropertyException</a>
|
||||
- Thrown if errors are detected while attempting to define a property of
|
||||
a host object from a Java class or method, or if a property is not found.</li>
|
||||
|
||||
<li>
|
||||
<a href="org/mozilla/javascript/NotAFunctionException.html">NotAFunctionException</a>
|
||||
- Thrown when attempting to call an object that is not a function.</li>
|
||||
<a href="org/mozilla/javascript/WrappedException.html">WrappedException</a>
|
||||
- Thrown by LiveConnect implementation from JavaScript when called Java method exits with an exception. It wraps the original Java exception.</li>
|
||||
|
||||
<li>
|
||||
<a href="org/mozilla/javascript/EvaluatorException.html">EvaluatorException</a>
|
||||
- An exception thrown when an error is detected during the execution of
|
||||
- An exception thrown when an error is detected during the compilation or execution of
|
||||
a script. The default error reporter will throw EvaluatorExceptions when
|
||||
an error is encountered.</li>
|
||||
</ul>
|
||||
|
||||
@@ -1,43 +1,74 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** 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.75 [en] (WinNT; U) [Netscape]">
|
||||
<meta name="KeyWords" content="Rhino, JavaScript, Java, BSF, Apache">
|
||||
<title>Rhino and BSF</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="KeyWords" content="Rhino, JavaScript, Java, BSF, Apache">
|
||||
<title>Rhino and BSF</title>
|
||||
<style>
|
||||
BODY { background-color: white }
|
||||
H1 { text-align: center }
|
||||
P { text-align: justify }
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF">
|
||||
<script src="owner.js"></script>
|
||||
<body>
|
||||
|
||||
<center>
|
||||
<h1>
|
||||
Using Rhino with BSF and Apache</h1></center>
|
||||
<script>document.write(owner());</script>
|
||||
<h1>Rhino and BSF</h1>
|
||||
|
||||
<br><script>
|
||||
var d = new Date(document.lastModified);
|
||||
document.write((d.getMonth()+1)+"/"+d.getDate()+"/"+d.getFullYear());
|
||||
document.write('<br>');
|
||||
</script>
|
||||
|
||||
<hr WIDTH="100%">
|
||||
<br>The <a href="http://oss.software.ibm.com/developerworks/projects/bsf">Bean
|
||||
<h2>What is BSF?</h2>
|
||||
<p>
|
||||
The <a href="http://jakarta.apache.org/bsf/">Bean
|
||||
Scripting Framework</a> (or BSF) was originally developed by IBM and now
|
||||
published as open source. It provides a framework for using a number of
|
||||
published as open source as a project at the Apache Software Foundation. It provides a framework for using a number of
|
||||
scripting languages with Java. Rhino is one of the supported languages.
|
||||
</p>
|
||||
|
||||
<p>This framework has been embedded in a number of open source projects,
|
||||
including the XSL processor <a href="http://xml.apache.org/xalan-j/index.html">Xalan</a>
|
||||
including the XSL processor <a href="http://xml.apache.org/xalan-j/">Xalan</a>
|
||||
and the XML/Java build tool <a href="http://ant.apache.org/">Ant</a>.
|
||||
<p>You can download a version of <tt>bsf.jar</tt> from <a href="http://oss.software.ibm.com/developerworks/projects/bsf">http://oss.software.ibm.com/developerworks/projects/bsf</a>
|
||||
that includes the <tt>com.ibm.bsf.engines.javascript.JavaScriptEngine</tt>
|
||||
class. The current version is 2.2 release candidate at the time of this
|
||||
writing. This version thus supports JavaScript through Rhino when used
|
||||
with the <tt>js.jar</tt> file from either <tt>rhino15R1.zip</tt> or <tt>rhinoTip.zip</tt>.
|
||||
<p>See <a href="http://xml.apache.org/xalan/extensions.html#ex-basic">Xalan-Java
|
||||
Extensions</a> for more information on adding JavaScript to XSL and the
|
||||
<a href="http://jakarta.apache.org/ant/jakarta-ant/docs/#script">Script
|
||||
task</a> for using scripting in Ant build files.
|
||||
See <a href="http://xml.apache.org/xalan-j/extensions.html">Xalan-Java
|
||||
Extensions</a> for more information on adding JavaScript to XSL and the description of the optional Script task in the
|
||||
<a href="http://ant.apache.org/manual/">Apache Ant Manual</a> for using scripting in Ant build files.
|
||||
</p>
|
||||
|
||||
<h2 id="bsf-issue">Using BSF with Rhino</h2>
|
||||
|
||||
<p>Now that the Apache Jakarta Bean Scripting Framework (BSF), version 2.4.0, has been officially released, you can use Rhino easily with BSF. See <a href="http://jakarta.apache.org/bsf/index.html">http://jakarta.apache.org/bsf/index.html</a>.
|
||||
</p>
|
||||
<p><a href="index.html">back to top</a>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,21 +1,78 @@
|
||||
<!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="Author" content="Norris Boyd">
|
||||
<meta name="KeyWords" content="Rhino, JavaScript, Java">
|
||||
<title>Change Log</title>
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!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="Igor Bukanov">
|
||||
<meta name="KeyWords" content="Rhino, JavaScript, Java">
|
||||
<title>Change Log</title>
|
||||
|
||||
<link rel="up" href="./" title="Rhino project page">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<body bgcolor="#ffffff">
|
||||
<p class="crumbs"><em>You are here:</em> <a href="./">Rhino project page</a> > <strong>Change Log</strong></p>
|
||||
|
||||
<h1 align="center">
|
||||
Change Log for Significant Rhino Changes</h1>
|
||||
<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
|
||||
2005-09-19</li>
|
||||
<li><a href="rhino16R1.html">Rhino 1.6R1</a>, released
|
||||
2004-11-29</li>
|
||||
<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
|
||||
2003-04-21</li>
|
||||
<li><a href="rhino15R4.html">Rhino 1.5R4</a>, released
|
||||
2003-02-10</li>
|
||||
<li><a href="rhino15R3.html">Rhino 1.5R3</a>, released
|
||||
2002-01-27</li>
|
||||
<li><a href="rhino15R2.html">Rhino 1.5R2</a>, released
|
||||
2001-07-27</li>
|
||||
<li><a href="rhino15R1.html">Rhino 1.5R1</a>, released
|
||||
2000-09-10</li>
|
||||
</ul>
|
||||
|
||||
This is a log of significant changes since Rhino 1.5 Release 4.
|
||||
|
||||
<h3>Nothing significant yet!</h3>
|
||||
|
||||
<hr width="100%"><br>
|
||||
<a href="index.html">back to top</a></h3>
|
||||
|
||||
</body></html>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,3 +1,37 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
|
||||
@@ -1,171 +1,182 @@
|
||||
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!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 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 Documentation</title>
|
||||
|
||||
<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>
|
||||
|
||||
<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 bgcolor="#ffffff">
|
||||
|
||||
<center>
|
||||
|
||||
<body>
|
||||
|
||||
<p class="crumbs"><em>You are here:</em> <a href="./">Rhino project page</a> > <strong>Rhino Documentation</strong></p>
|
||||
|
||||
<h1> Rhino Documentation</h1>
|
||||
</center>
|
||||
<b><i><font size="+1">General</font></i></b>
|
||||
<table width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><a href="overview.html">Overview</a>
|
||||
</td>
|
||||
<td>An overview of the JavaScript language and of Rhino.</td>
|
||||
|
||||
<h2><a name="general" id="general">General</a></h2>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th><a href="overview.html">Overview</a></th>
|
||||
<td>An overview of the JavaScript language and of Rhino.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="limits.html">Requirements and Limitations</a>
|
||||
</td>
|
||||
<td>What you must have to run Rhino; what Rhino cannot do.</td>
|
||||
<tr>
|
||||
<th><a href="limits.html">Requirements and Limitations</a></th>
|
||||
<td>What you must have to run Rhino; what Rhino cannot do.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="rhino15R4.html">What's new in 1.5R4</a>
|
||||
</td>
|
||||
<td>Changes since 1.5R3.</td>
|
||||
<tr>
|
||||
<th><a href="changes.html">Change log</a></th>
|
||||
<td>Recent Rhino Changes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="debugger.html">Rhino Debugger</a>
|
||||
</td>
|
||||
<td>A debugger for debugging JavaScript running in Rhino.</td>
|
||||
<tr>
|
||||
<th><a href="opt.html">Optimization</a></th>
|
||||
<td>Details on the various optimization levels.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="opt.html">Optimization</a>
|
||||
</td>
|
||||
<td>Details on the various optimization levels.</td>
|
||||
<tr>
|
||||
<th><a href="faq.html">FAQ</a></th>
|
||||
<td>Answers to frequently asked questions about Rhino.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="http://sourceforge.net/projects/jscorba">JS/CORBA Adapter</a>
|
||||
</td>
|
||||
<td>Provides a mechanism for arbitrary JavaScript objects to interact
|
||||
with each other transparently in a distributed JavaScript system using CORBA.</td>
|
||||
<tr>
|
||||
<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>
|
||||
<tr>
|
||||
<td><a href="bsf.html">Using Rhino with BSF and Apache</a>
|
||||
</td>
|
||||
<td>How to use Rhino with apps that support BSF.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="changes.html">Recent Changes</a>
|
||||
</td>
|
||||
<td>Describes recent changes to Rhino.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="faq.html">FAQ</a>
|
||||
</td>
|
||||
<td>Answers to frequently asked questions about Rhino.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="http://industry.java.sun.com/javaone/99/event/0,1768,629,00.html">
|
||||
1999 JavaOne session on Rhino</a>
|
||||
</td>
|
||||
<td>A talk on Rhino with slides. Also see the <a href="javaone.html">followup</a>
|
||||
.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="Top"><a href="http://www.ociweb.com/jnb/archive/jnbMar2001.html">
|
||||
Scripting Languages for Java</a>
|
||||
<br>
|
||||
</td>
|
||||
<td valign="Top">An article comparing and contrasting Rhino and Jython.<br>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p><b><i><font size="+1">Writing Scripts</font></i></b>
|
||||
<table width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><a href="ScriptingJava.html">Scripting Java</a>
|
||||
</td>
|
||||
<td>How to use Rhino to script Java classes.</td>
|
||||
|
||||
<h2><a name="scripts" id="scripts">Writing Scripts</a></h2>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th><a href="ScriptingJava.html">Scripting Java</a></th>
|
||||
<td>How to use Rhino to script Java classes.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="scriptjava.html">Scripting Java</a>
|
||||
</td>
|
||||
<td>How to use Rhino to script Java classes (an older treatment).</td>
|
||||
<tr>
|
||||
<th><a href="scriptjava.html">Scripting Java</a></th>
|
||||
<td>How to use Rhino to script Java classes (an older treatment).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="perf.html">Performance Hints</a>
|
||||
</td>
|
||||
<td>Some tips on writing faster JavaScript code.</td>
|
||||
<tr>
|
||||
<th><a href="perf.html">Performance Hints</a></th>
|
||||
<td>Some tips on writing faster JavaScript code.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="tools.html">Tools</a>
|
||||
</td>
|
||||
<td>Some tools for developing JavaScript scripts.</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</p>
|
||||
|
||||
<p><b><i><font size="+1">Embedding Rhino</font></i></b>
|
||||
<table width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><a href="tutorial.html">Embedding tutorial</a>
|
||||
</td>
|
||||
<td>A short tutorial on how to embed Rhino into your application.</td>
|
||||
|
||||
<h2><a name="javascript" id="javascript">JavaScript Tools</a></h2>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th><a href="shell.html">JavaScript Shell</a></th>
|
||||
<td>Interactive or batch execution of scripts.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="apidocs/index.html">API javadoc Reference</a>
|
||||
</td>
|
||||
<td>An annotated outline of the programming interface to Rhino (tip only).</td>
|
||||
<tr>
|
||||
<th><a href="debugger.html">JavaScript Debugger</a></th>
|
||||
<td>Debugging scripts running in Rhino.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="scopes.html">Scopes and Contexts</a>
|
||||
</td>
|
||||
<td>Describes how to use scopes and contexts for the best performance
|
||||
and flexibility, with an eye toward multithreaded environments.</td>
|
||||
<tr>
|
||||
<th><a href="jsc.html">JavaScript Compiler</a></th>
|
||||
<td>Compiling scripts into Java class files.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="serialization.html">Serialization</a>
|
||||
</td>
|
||||
<td>How to serialize JavaScript objects and functions in Rhino.</td>
|
||||
<tr>
|
||||
<th><a href="../js/tests/library.html">Testing</a></th>
|
||||
<td>Running the JavaScript test suite.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="runtime.html">Runtime</a>
|
||||
</td>
|
||||
<td>A brief description of the JavaScript runtime.</td>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h2><a name="embedding" id="embedding">Embedding Rhino</a></h2>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th><a href="tutorial.html">Embedding tutorial</a></th>
|
||||
<td>A short tutorial on how to embed Rhino into your application.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="footprint.html">Small Footprint</a>
|
||||
</td>
|
||||
<td>Hints for those interested in small-footprint embeddings.</td>
|
||||
<tr>
|
||||
<th><a href="apidocs/">API javadoc Reference</a></th>
|
||||
<td>An annotated outline of the programming interface to Rhino
|
||||
(tip only).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="examples.html">Examples</a>
|
||||
</td>
|
||||
<td>A set of examples showing how to control the JavaScript engine and
|
||||
<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>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><a href="serialization.html">Serialization</a></th>
|
||||
<td>How to serialize JavaScript objects and functions in Rhino.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><a href="runtime.html">Runtime</a></th>
|
||||
<td>A brief description of the JavaScript runtime.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><a href="footprint.html">Small Footprint</a></th>
|
||||
<td>Hints for those interested in small-footprint embeddings.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><a href="examples.html">Examples</a></th>
|
||||
<td>A set of examples showing how to control the JavaScript engine and
|
||||
build JavaScript host objects.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><font color="#000000"><a href="http://www.mozilla.org/js/tests/library.html">
|
||||
Testing</a>
|
||||
</font></td>
|
||||
<td>How to run the JavaScript test suite.</td>
|
||||
<tr>
|
||||
<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>
|
||||
</tbody>
|
||||
</table>
|
||||
</p>
|
||||
|
||||
<h3>
|
||||
<hr width="100%"><a href="index.html">back to top</a>
|
||||
</h3>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,91 +1,203 @@
|
||||
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!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>Rhino is available for download both in source and compiled form. </p>
|
||||
<h3> Binaries</h3>
|
||||
You can download binaries (JAR files) from <a
|
||||
href="ftp://ftp.mozilla.org/pub/mozilla.org/js/"> ftp://ftp.mozilla.org/pub/mozilla.org/js/</a>
|
||||
. Rhino 1.5 Release 4.1 is the last qualified release. It is also possible
|
||||
to download the latest rhino build that reflects newer features and bug
|
||||
fixes, but has not been fully qualified. These zip files also include
|
||||
the source.
|
||||
<p>If you are looking for <tt>js.jar</tt> for XSLT or for IBM's Bean
|
||||
Scripting Framework (BSF), download one of the zip files below and
|
||||
unzip it. </p>
|
||||
<ul>
|
||||
|
||||
<li> <a href="ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino15R41.zip">Rhino 1.5R4.1.</a>
|
||||
<ul>
|
||||
<li> <i><font size="-1"><a href="rhino15R41.html">Description of changes from 1.5R4.1</a> </font></i>.</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li> <a href="ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino15R4.zip">Rhino 1.5R4.</a>
|
||||
<ul>
|
||||
<li> <i><font size="-1"><a href="rhino15R4.html">Description of changes from 1.5R3</a> </font></i>.</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li><a href="ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino15R3.zip">Rhino 1.5R3.</a>
|
||||
<ul>
|
||||
<li> <i><font size="-1"><a href="rhino15R3.html">Description of
|
||||
changes from 1.5R2</a> </font></i>.</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li> <a
|
||||
href="ftp://ftp.mozilla.org/pub/mozilla.org/js/older-packages/rhino15R2.zip">Rhino
|
||||
1.5R2.</a>
|
||||
<ul>
|
||||
<li> <i><font size="-1"><a href="rhino15R2.html">Description of
|
||||
changes from 1.5R1</a> </font></i>.</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li><a
|
||||
href="ftp://ftp.mozilla.org/pub/mozilla.org/js/older-packages/rhino15R1.zip">Rhino
|
||||
1.5R1.</a>
|
||||
<ul>
|
||||
<li> <i><font size="-1"><a href="rhino15R1.html">Description of
|
||||
changes from 1.4R3</a> </font></i>.</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li> <a
|
||||
href="ftp://ftp.mozilla.org/pub/mozilla.org/js/older-packages/rhino14R3.zip"> Rhino
|
||||
1.4 Release 3</a> .</li>
|
||||
|
||||
<li> <a href="ftp://ftp.mozilla.org/pub/mozilla.org/js/rhinoLatest.zip">Latest
|
||||
Rhino builds</a> .
|
||||
<ul>
|
||||
<li> <i><font size="-1"><a href="changes.html">Description of
|
||||
changes from 1.5R4</a> </font></i>.</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
<h3> Source</h3>
|
||||
The source code for Rhino is available under <a
|
||||
href="http://www.mozilla.org/NPL/"> NPL 1.1</a> . 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> cvs co mozilla/js/rhino</pre>
|
||||
to get the tip source.
|
||||
<p class="crumbs"><em>You are here:</em> <a href="./">Rhino project page</a> > <strong>Rhino Downloads</strong></p>
|
||||
|
||||
<h1>Rhino Downloads</h1>
|
||||
<p>Rhino is available for download both in source and compiled form. </p>
|
||||
|
||||
<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 <code class="filename">js.jar</code>
|
||||
with all Rhino classes, documentation, examples and sources.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Rhino 1.6R5 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 class="data">
|
||||
<thead>
|
||||
<tr>
|
||||
<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>
|
||||
|
||||
<tr>
|
||||
<td>Rhino 1.6R5</td>
|
||||
<td>2006-11-19</td>
|
||||
<td>Same code as 1.6R4, but relicensed under MPL/GPL.</a></td>
|
||||
<td><a href="ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_6R5.zip">rhino1_6R5.zip</a></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Rhino 1.6R4</td>
|
||||
<td>2006-09-10</td>
|
||||
<td><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=343976">bug 343976</a></td>
|
||||
<td><a href="ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_6R4.zip">rhino1_6R4.zip</a></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Rhino 1.6R3</td>
|
||||
<td>2006-07-24</td>
|
||||
<td><a href="rhino16R3.html">Changes in 1.6R3</a></td>
|
||||
<td><a href="ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_6R3.zip">rhino1_6R3.zip</a></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Rhino 1.6R2</td>
|
||||
<td>2005-09-19</td>
|
||||
<td><a href="rhino16R2.html">Changes in 1.6R2</a></td>
|
||||
<td><a href="ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_6R2.zip">rhino1_6R2.zip</a></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Rhino 1.6R1</td>
|
||||
<td>2004-11-29</td>
|
||||
<td><a href="rhino16R1.html">Changes in 1.6R1</a></td>
|
||||
<td><a href="ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_6R1.zip">rhino1_6R1.zip</a></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Rhino 1.5R5</td>
|
||||
<td>2004-03-25</td>
|
||||
<td><a href="rhino15R5.html">Changes in 1.5R5</a></td>
|
||||
<td><a href="ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_5R5.zip">rhino1_5R5.zip</a></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Rhino 1.5R4.1</td>
|
||||
<td>2003-04-21</td>
|
||||
<td><a href="rhino15R41.html">Changes in 1.5R4.1</a></td>
|
||||
<td><a href="ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino15R41.zip">rhino15R41.zip</a></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Rhino 1.5R4</td>
|
||||
<td>2003-02-10</td>
|
||||
<td><a href="rhino15R4.html">Changes in 1.5R4</a></td>
|
||||
<td><a href="ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino15R4.zip">rhino15R4.zip</a></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Rhino 1.5R3</td>
|
||||
<td>2002-01-27</td>
|
||||
<td><a href="rhino15R3.html">Changes in 1.5R3</a></td>
|
||||
<td><a href="ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino15R3.zip">rhino15R3.zip</a></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Rhino 1.5R2</td>
|
||||
<td>2001-07-27</td>
|
||||
<td><a href="rhino15R2.html">Changes in 1.5R2</a></td>
|
||||
<td><a href="ftp://ftp.mozilla.org/pub/mozilla.org/js/older-packages/rhino15R2.zip">rhino15R2.zip</a></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Rhino 1.5R1</td>
|
||||
<td>2000-09-10</td>
|
||||
<td><a href="rhino15R1.html">Changes in 1.5R1</a></td>
|
||||
<td><a href="ftp://ftp.mozilla.org/pub/mozilla.org/js/older-packages/rhino15R1.zip">rhino15R1.zip</a></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Rhino 1.4R3</td>
|
||||
<td>1999-05-10</td>
|
||||
<td>Initial public release</td>
|
||||
<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 <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>
|
||||
|
||||
<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</a> 1.1/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"> 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> . </p>
|
||||
<p> </p>
|
||||
<hr width="100%"><a href="index.html">back to top</a> <br>
|
||||
<br>
|
||||
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 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>
|
||||
|
||||
@@ -1,3 +1,37 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
@@ -52,7 +86,7 @@ JScript. Microsoft binaries of jscript engine can be downloaded from http://msdn
|
||||
language in detail but explains how these scripting engines can be used
|
||||
as host to expose business objects in the middle-tier and how the user
|
||||
of these applications can extend it if needed using JavaScript.</font></font>
|
||||
<p><font face="Arial"><font size=-1>The scripting engine Rhino (<a href="http://www.mozilla.org/js)">www.mozilla.org/rhino)</a>,
|
||||
<p><font face="Arial"><font size=-1>The scripting engine Rhino (<a href="./)">www.mozilla.org/rhino)</a>,
|
||||
a javascript engine purely written in Java is one that I am going to use
|
||||
for the testing the above.</font></font>
|
||||
<p><font face="Arial"><font size=-1>Let us set some simple goals,</font></font>
|
||||
@@ -161,7 +195,7 @@ jsbuff){</font></font>
|
||||
<br><font face="Arial"><font size=-1>Object any=null;</font></font>
|
||||
<br><font face="Arial"><font size=-1>try{</font></font>
|
||||
<br><i><font face="Arial"><font size=-1>//Enter the Context</font></font></i>
|
||||
<br><font face="Arial"><font size=-1><i>// Refer </i><u><font color="#0000FF">http://www.mozilla.org/js/rhino/tutorial.html</font></u></font></font>
|
||||
<br><font face="Arial"><font size=-1><i>// Refer </i><u><font color="#0000FF">http://www.mozilla.org/rhino/tutorial.html</font></u></font></font>
|
||||
<br><font face="Arial"><font size=-1>Context context = Context.enter();</font></font>
|
||||
<br><i><font face="Arial"><font size=-1>// Get the execution scope</font></font></i>
|
||||
<br><font face="Arial"><font size=-1>Scriptable scope = context.initStandardObjects();</font></font>
|
||||
@@ -183,7 +217,7 @@ to this create object instance</font></font></i>
|
||||
scope);</font></font>
|
||||
<br><font face="Arial"><font size=-1>scope.put("create",scope,create);</font></font>
|
||||
<br><i><font face="Arial"><font size=-1>//Evaluate (or execute js)</font></font></i>
|
||||
<br><font face="Arial"><font size=-1><i>//Refer </i><u><font color="#0000FF">http://www.mozilla.org/js/rhino/tutorial.html</font></u></font></font>
|
||||
<br><font face="Arial"><font size=-1><i>//Refer </i><u><font color="#0000FF">http://www.mozilla.org/rhino/tutorial.html</font></u></font></font>
|
||||
<br><font face="Arial"><font size=-1>any = context.evaluateString(scope,
|
||||
jsbuff, "", 1, null);</font></font>
|
||||
<br><i><font face="Arial"><font size=-1>//Exit the Context</font></font></i>
|
||||
@@ -266,8 +300,8 @@ file - " + args[0]);</font></font>
|
||||
<br>
|
||||
<br>
|
||||
<p><font face="Arial"><font size=-1>For more explanations on the code execution,
|
||||
please refer embedding tutorial <a href="http://www.mozilla.org/js/rhino/tutorial.html">http://www.mozilla.org/js/rhino/tutorial.html</a>
|
||||
and for all documentation and examples on Rhino visit <a href="http://www.mozilla.org/rhino/doc.html">http://www.mozilla.org/rhino/doc.html</a>.</font></font>
|
||||
please refer embedding tutorial <a href="http://www.mozilla.org/rhino/tutorial.html">http://www.mozilla.org/rhino/tutorial.html</a>
|
||||
and for all documentation and examples on Rhino visit <a href="doc.html">http://www.mozilla.org/rhino/doc.html</a>.</font></font>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
@@ -1,3 +1,37 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
@@ -68,7 +102,7 @@ by only performing that expensive operation once.
|
||||
<br>
|
||||
<h2>
|
||||
Implementing Host Objects</h2>
|
||||
First check out the <a href="http://www.mozilla.org/rhino/tutorial.html">tutorial</a>
|
||||
First check out the <a href="tutorial.html">tutorial</a>
|
||||
if you haven't already.
|
||||
<h4>
|
||||
The Foo class - Extending ScriptableObject</h4>
|
||||
|
||||
@@ -1,52 +1,86 @@
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!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> >
|
||||
<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>
|
||||
|
||||
@@ -1,3 +1,37 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
@@ -22,8 +56,8 @@ Most embeddings won't need any of the classes in <tt>org.mozilla.javascript.tool
|
||||
Optimizer</h3>
|
||||
<p>
|
||||
It is possible to run Rhino with interpreter mode only, allowing you to remove
|
||||
classes for classfile generation that include all the classes from
|
||||
<tt>org.mozilla.javascript.optimizer</tt> package and <tt>ClassNameHelper</tt>, <tt>ClassRepository</tt> classes from <tt>org.mozilla.javascript</tt> package.
|
||||
code for classfile generation that include all the classes from
|
||||
<tt>org.mozilla.javascript.optimizer</tt> package.
|
||||
|
||||
<h3>JavaAdapter</h3>
|
||||
<p>
|
||||
@@ -32,7 +66,7 @@ classes on the fly. Removing <tt>org.mozilla.javascript.JavaAdapter</tt> will di
|
||||
|
||||
<h3>Class generation library</h3>
|
||||
<p>
|
||||
If you do not include Optimizer or JavaAdapter, then you do not need Rhino library for class file generation and you can remove all the classes from in <tt>org.mozilla.classfile</tt> package.
|
||||
If you do not include Optimizer or JavaAdapter, nor do you use PolicySecurityController then you do not need Rhino library for class file generation and you can remove all the classes from in <tt>org.mozilla.classfile</tt> package.
|
||||
|
||||
<h3>Regular Expressions</h3>
|
||||
<p>
|
||||
@@ -45,13 +79,19 @@ expression matches. This change saves 47,984 bytes of class files.
|
||||
Debug information in Rhino classes consumes about 25% of code size and if you can live without that, you can recompile Rhino to remove it.
|
||||
|
||||
<h2>smalljs.jar</h2>
|
||||
|
||||
Ant build script in Rhino supports smalljar target that will generate smalljs.jar that does not include Tools, Optimizer, JavaAdapter and Class generation library, Regular Expressions and deprecated files. To build such minimalist jar without debug information, run the following command from the top directory of Rhino distribution:
|
||||
<p>
|
||||
Ant build script in Rhino supports smalljar target that will generate
|
||||
smalljs.jar that does not include Tools, Optimizer, JavaAdapter and Class
|
||||
generation library, Regular Expressions, E4X implementataion and deprecated
|
||||
files. To build such minimalist jar without debug information, run the
|
||||
following command from the top directory of Rhino distribution:
|
||||
<pre>
|
||||
ant clean
|
||||
ant -Ddebug=off -Dno-regexp=true smalljar
|
||||
ant -Ddebug=off -Dno-regexp=true -Dno-e4x=true smalljar
|
||||
</pre>
|
||||
If you omit <tt>-Dno-regexp=true</tt>, then the resulting smalljs.jar will include Regular Expression support.
|
||||
If you omit <tt>-Dno-regexp=true</tt>, then the resulting smalljs.jar will
|
||||
include Regular Expression support. Similarly omitting <tt>-Dno-e4x=true</tt>
|
||||
results in smalljs.jar that includes runtime support for E4X.
|
||||
|
||||
<p>
|
||||
<hr WIDTH="100%">
|
||||
|
||||
@@ -1,44 +1,90 @@
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!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 name="Author" content="Norris Boyd">
|
||||
<meta name="GENERATOR" content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]">
|
||||
<title>Help with Rhino</title>
|
||||
|
||||
<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 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>
|
||||
|
||||
<center><b><font size=+3>Help with Rhino</font></b></center>
|
||||
<script src="owner.js"></script>
|
||||
<p class="crumbs"><em>You are here:</em> <a href="./">Rhino project page</a> > <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:
|
||||
<br>
|
||||
<h3>
|
||||
<font size=+1>Newsgroup and Mail Gateway</font></h3>
|
||||
The <a href="news:netscape.public.mozilla.jseng">netscape.public.mozilla.jseng</a>
|
||||
newsgroup answers questions about both Rhino and the C implementation of
|
||||
JavaScript. You can get to the newsgroup through a mail gateway. Send a
|
||||
message with the subject "subscribe" to <a href="mailto:mozilla-jseng-request@mozilla.org?subject=subscribe">mozilla-jseng-request@mozilla.org</a>.
|
||||
To post messages, send mail to <a href="mailto:mozilla-jseng@mozilla.org">mozilla-jseng@mozilla.org</a>.
|
||||
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>
|
||||
|
||||
<h2><a name="newsgroups" id="newsgroups">Newsgroup and Mail Gateway</a></h2>
|
||||
<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
|
||||
The <a href="news://news.mozilla.org/mozilla.dev.tech.js-engine">mozilla.dev.tech.js-engine</a>
|
||||
newsgroup answers questions about both Rhino and the C implementation of
|
||||
JavaScript. Click <a href="https://lists.mozilla.org/listinfo/dev-tech-js-engine">here</a> to subscribe/unsubscribe.
|
||||
</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
|
||||
other newsgroup services.
|
||||
<h3>
|
||||
Bug System</h3>
|
||||
Use <a href="http://bugzilla.mozilla.org/enter_bug.cgi?product=Rhino">Bugzilla</a>
|
||||
</p>
|
||||
|
||||
<h2>Bug System</h2>
|
||||
<p>
|
||||
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.
|
||||
<br>
|
||||
<h3>
|
||||
Module Owner</h3>
|
||||
The module owner, <script>document.write(owner());</script>
|
||||
, can
|
||||
</p>
|
||||
|
||||
<h2>Module Owner</h2>
|
||||
<p>
|
||||
The module owner, <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>
|
||||
<hr WIDTH="100%"><a href="index.html">back to top</a>
|
||||
<br>
|
||||
<br>
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,75 +1,66 @@
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!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 name="Author" content="Norris Boyd">
|
||||
<meta name="GENERATOR" content="Mozilla/4.7 [en] (WinNT; U) [Netscape]">
|
||||
<meta name="KeyWords" content="Rhino, JavaScript, Java, Mozilla">
|
||||
<title>Rhino - JavaScript for Java</title>
|
||||
<title>Rhino - JavaScript for Java</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Rhino: JavaScript for Java</h1>
|
||||
<p style="text-align:center"><img src="rhino50.jpg" height="200" width="398" alt="">
|
||||
<p>Rhino is an open-source implementation of JavaScript written
|
||||
entirely in Java. It is typically embedded into Java applications to provide
|
||||
scripting to end users.
|
||||
<dl>
|
||||
<dt><a href="download.html">Downloads</a>
|
||||
<dd>How to get source and binaries.
|
||||
<dt><a href="doc.html">Documentation</a>
|
||||
<dd>Information on Rhino for script writers and embedders.
|
||||
<dt><a href="history.html">History</a>
|
||||
<dd>The ancestry of the beast.
|
||||
<dt><a href="help.html">Help</a>
|
||||
<dd>Some resources if you get stuck.
|
||||
<dt><a href="users.html">Users</a>
|
||||
<dd>How people are using Rhino.
|
||||
</dl>
|
||||
<address>Module owner: <a href="mailto:nboyd@atg.com">Norris Boyd</a></address>
|
||||
<p class="note">Rhino image courtesy of Paul Houle.
|
||||
<p class="remark">Add reference to
|
||||
http://www.javaworld.com/jw-08-1999/jw-08-howto.html
|
||||
and
|
||||
http://www.javaworld.com/javaworld/jw-09-1999/jw-09-howto.html
|
||||
|
||||
<center>
|
||||
<h1>
|
||||
Rhino: JavaScript for Java</h1></center>
|
||||
|
||||
<center><img SRC="rhino50.jpg" height=200 width=398></center>
|
||||
|
||||
<hr WIDTH="100%">Rhino is an open-source implementation of JavaScript written
|
||||
entirely in Java. It is typically embedded into Java applications to provide
|
||||
scripting to end users.
|
||||
<table WIDTH="100%" >
|
||||
<tr>
|
||||
<td>
|
||||
<div align=right><b><a href="download.html">Downloads</a></b></div>
|
||||
</td>
|
||||
|
||||
<td>How to get source and binaries.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<div align=right><b><a href="doc.html">Documentation</a></b></div>
|
||||
</td>
|
||||
|
||||
<td>Information on Rhino for script writers and embedders.</td>
|
||||
</tr>
|
||||
|
||||
<!--
|
||||
<tr>
|
||||
<td>
|
||||
<div align=right><b><a href="users.html">Users</a></b></div>
|
||||
</td>
|
||||
|
||||
<td>How people are using Rhino.</td>
|
||||
</tr>
|
||||
-->
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<div align=right><b><a href="history.html">History</a></b></div>
|
||||
</td>
|
||||
|
||||
<td>The ancestry of the beast.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<div align=right><b><a href="help.html">Help</a></b></div>
|
||||
</td>
|
||||
|
||||
<td>Some resources if you get stuck.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<hr WIDTH="100%"><font size=-1>Module owner </font><script src="owner.js"></script>
|
||||
<script>document.write(owner());</script>
|
||||
|
||||
<br><font size=-1>Rhino image courtesy of Paul Houle.</font><!---
|
||||
Add reference to
|
||||
http://www.javaworld.com/jw-08-1999/jw-08-howto.html
|
||||
and
|
||||
http://www.javaworld.com/javaworld/jw-09-1999/jw-09-howto.html
|
||||
--->
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
@@ -1,3 +1,37 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
@@ -33,7 +67,7 @@ so people can ask addition questions or comments there.
|
||||
Java classes visible to scripts</h3>
|
||||
One attendee raised the point that many embeddings may not want scripts
|
||||
to be able to access all Java classes. This is an excellent point, and
|
||||
I've implemented an addition to the <a href="../js/rhino/org/mozilla/javascript/SecuritySupport.html">SecuritySupport</a>
|
||||
I've implemented an addition to the <a href="apidocs/org/mozilla/javascript/SecuritySupport.html">SecuritySupport</a>
|
||||
class that allows embedders to choose which classes are exposed to scripts.
|
||||
<h3>
|
||||
Easier "importing" of Java classes</h3>
|
||||
@@ -42,7 +76,7 @@ classes (like <tt>java.lang.String</tt> or <tt>Packages.org.mozilla.javascript.C
|
||||
could be improved. I've implemented a set of changes that make importing
|
||||
easier, but I'm not convinced that adding them is the right thing to do
|
||||
due to some drawbacks.
|
||||
<p>To see what I've done, take a look at the javadoc for the <a href="../js/rhino/org/mozilla/javascript/ImporterTopLevel.html">ImporterTopLevel</a>
|
||||
<p>To see what I've done, take a look at the javadoc for the <a href="apidocs/org/mozilla/javascript/ImporterTopLevel.html">ImporterTopLevel</a>
|
||||
class. You'll see that it's now possible to make function calls to "import"
|
||||
Java classes so that they can be referred to without qualification. I didn't
|
||||
use the word "import" because that's a keyword in JavaScript.
|
||||
|
||||
@@ -1,3 +1,37 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
@@ -59,7 +93,7 @@ periods.</ul>
|
||||
<tt>-version </tt><i>versionNumber</i>
|
||||
<ul>Specifies the language version to compile with. The string <i>versionNumber</i>
|
||||
must be one of <tt>100</tt>, <tt>110</tt>, <tt>120</tt>, <tt>130</tt>,
|
||||
or <tt>140</tt>. See <a href="overview.html#versions">JavaScript Language
|
||||
<tt>140</tt>, <tt>150</tt>, or <tt>160</tt>. See <a href="overview.html#versions">JavaScript Language
|
||||
Versions</a> for more information on language versions.</ul>
|
||||
|
||||
<h2>
|
||||
|
||||
@@ -1,86 +1,136 @@
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!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> > <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>
|
||||
<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>
|
||||
<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> Sun Oct 25 02:00:00 GMT-0800 (PST) 1998</pre>
|
||||
Earlier versions may return:
|
||||
<pre> 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="rhino.html">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>
|
||||
|
||||
@@ -1,68 +1,107 @@
|
||||
<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">
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<CENTER>
|
||||
<H1>
|
||||
Optimization</H1></CENTER>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
|
||||
<H2>
|
||||
Optimization settings</H2>
|
||||
<P>The currently supported optimization settings are:</P>
|
||||
<html lang="en">
|
||||
|
||||
<P><B>-1</B>
|
||||
<head>
|
||||
|
||||
<P><B></B>Interpretive mode is always
|
||||
used. The compilation time is minimized at the expense of runtime performance.
|
||||
No class files are generated, which may improve memory usage depending on your
|
||||
system.
|
||||
<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> > <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
|
||||
memory usage depending on your system. Another benefit of the interpreted mode
|
||||
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><B></B>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 & 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 & 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>
|
||||
|
||||
@@ -1,55 +1,106 @@
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!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> > <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.ch/ecma1/STAND/ECMA-262.HTM">downloaded</a> or
|
||||
obtained by mail from ECMA, 114 Rue du Rhône, CH1204 Geneva, Switzerland.
|
||||
<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ô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>
|
||||
<br>
|
||||
<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
|
||||
@@ -57,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>
|
||||
<br>
|
||||
<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>
|
||||
<br>
|
||||
<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>
|
||||
<br>
|
||||
<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>
|
||||
|
||||
@@ -1,3 +1,49 @@
|
||||
function owner() {
|
||||
return '<a href="mailto:nboyd'+'@'+ 'atg.com">Norris Boyd</a>'
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
function owner()
|
||||
{
|
||||
return email("Norris Boyd", "nboyd", "atg.com");
|
||||
}
|
||||
|
||||
function email(name, prefix, suffix)
|
||||
{
|
||||
return "<a href='mailto:"+prefix+"@"+suffix+"'>"+name+"</a>";
|
||||
}
|
||||
|
||||
function write_email(name, prefix, suffix)
|
||||
{
|
||||
document.write(email(name, prefix, suffix));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,83 +1,154 @@
|
||||
<!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">
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!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> > <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 < 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 < a.length; i++)
|
||||
result += a[i];
|
||||
return result;
|
||||
}
|
||||
</pre>
|
||||
|
||||
<center>
|
||||
<h1>
|
||||
Performance Hints</h1></center>
|
||||
<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> result = 0;</tt>
|
||||
<br><tt> for (i=0; i <
|
||||
a.length; i++)</tt>
|
||||
<br><tt> result += a[i];</tt>
|
||||
<br><tt> return result;</tt>
|
||||
<br><tt>}</tt>
|
||||
<p>as
|
||||
<p><tt>function sum(a) {</tt>
|
||||
<br><tt> var result = 0;</tt>
|
||||
<br><tt> for (var i=0; i
|
||||
< a.length; i++)</tt>
|
||||
<br><tt> result += a[i];</tt>
|
||||
<br><tt> 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>
|
||||
<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 < n; i++)</tt>
|
||||
<br><tt> 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("a", "b", "c")</tt> or <tt>["a", "b", "c"]</tt> will cause a 3-element
|
||||
Java array to be allocated to hold the contents of the JavaScript array.
|
||||
<br>
|
||||
<br>
|
||||
<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> this.s = a;</tt>
|
||||
<br><tt> this.toString = new
|
||||
Function("return this.s");</tt>
|
||||
<br><tt>}</tt>
|
||||
<p>could be written more efficiently as
|
||||
<p><tt>function MyObject(a) {</tt>
|
||||
<br><tt> this.s = a;</tt>
|
||||
<br><tt> 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> </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>
|
||||
<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 < 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("a", "b", "c")</code><br>
|
||||
or<br>
|
||||
<code>["a", "b", "c"]</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("return this.s");
|
||||
}
|
||||
</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>
|
||||
|
||||
@@ -1,3 +1,37 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
@@ -80,7 +114,7 @@ command line. This is <tt>jsc</tt>, the JavaScript compiler. This tool
|
||||
can be used to create Java classes from JavaScript. Options exist to allow
|
||||
creation of Java classes that implement arbitrary interfaces and extend
|
||||
arbitrary base classes, allowing JavaScript scripts to implement important
|
||||
protocols like applets and servlets. See <a href="http://www.mozilla.org/rhino/jsc.html">http://www.mozilla.org/rhino/jsc.html</a>.
|
||||
protocols like applets and servlets. See <a href="jsc.html">http://www.mozilla.org/rhino/jsc.html</a>.
|
||||
<br>
|
||||
<h3>
|
||||
LiveConnect 3</h3>
|
||||
@@ -102,7 +136,7 @@ useful for multithreaded environments like server embeddings.
|
||||
New semantics for <tt>ScriptableObject.defineClass</tt></h3>
|
||||
The old rules for defining JavaScript objects using a Java class were getting
|
||||
baroque. Those rules are still supported, but a cleaner definition is now
|
||||
supported. See the <a href="http://www.mozilla.org/js/rhino/org/mozilla/javascript/ScriptableObject.html#defineClass(org.mozilla.javascript.Scriptable, java.lang.Class)">javadoc</a>
|
||||
supported. See the <a href="apidocs/org/mozilla/javascript/ScriptableObject.html#defineClass(org.mozilla.javascript.Scriptable, java.lang.Class)">javadoc</a>
|
||||
for details.
|
||||
<br>
|
||||
<h3>
|
||||
@@ -119,7 +153,7 @@ variables.
|
||||
Java classes visible to scripts</h3>
|
||||
An attendee at JavaOne raised the point that many embeddings may not want
|
||||
scripts to be able to access all Java classes. This is an excellent point,
|
||||
and I've implemented an addition to the <a href="../js/rhino/org/mozilla/javascript/SecuritySupport.html">SecuritySupport</a>
|
||||
and I've implemented an addition to the <a href="apidocs/org/mozilla/javascript/SecuritySupport.html">SecuritySupport</a>
|
||||
interface that allows embedders to choose which classes are exposed to
|
||||
scripts.
|
||||
<br>
|
||||
@@ -127,7 +161,7 @@ scripts.
|
||||
SecuritySupport and JavaAdapter</h3>
|
||||
Andrew Wason pointed a problem with the new JavaAdapter feature (which
|
||||
allows JavaScript objects to implement arbitrary Java interfaces by generating
|
||||
class files). It didn't support the <a href="../js/rhino/org/mozilla/javascript/SecuritySupport.html">SecuritySupport</a>
|
||||
class files). It didn't support the <a href="apidocs/org/mozilla/javascript/SecuritySupport.html">SecuritySupport</a>
|
||||
interface, which allows Rhino to delegate the creation of classes from
|
||||
byte arrays to a routine provided by the embedding. This ability is important
|
||||
from a security standpoint because class creation is considered a privileged
|
||||
@@ -140,14 +174,14 @@ will delegate class creation to the SecuritySupport class.
|
||||
Context.exit()</h3>
|
||||
Context.exit() has been changed from an instance method to a static method.
|
||||
This makes it match the Context.enter() method, which is also static. See
|
||||
the <a href="http://www.mozilla.org/js/rhino/org/mozilla/javascript/Context.html#exit()">javadoc</a>
|
||||
the <a href="apidocs/org/mozilla/javascript/Context.html#exit()">javadoc</a>
|
||||
for more information on its operation.
|
||||
<br>
|
||||
<h3>
|
||||
Context.enter(Context)</h3>
|
||||
A new overloaded form of Context.enter has been added. Without the addition
|
||||
of this method it was not possible to attach an existing context to a thread.
|
||||
See the <a href="http://www.mozilla.org/js/rhino/org/mozilla/javascript/Context.html#enter(org.mozilla.javascript.Context)">javadoc</a>
|
||||
See the <a href="apidocs/org/mozilla/javascript/Context.html#enter(org.mozilla.javascript.Context)">javadoc</a>
|
||||
for more information on its operation.
|
||||
<br>
|
||||
<h3>
|
||||
|
||||
@@ -1,3 +1,37 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
|
||||
@@ -1,3 +1,37 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
|
||||
@@ -1,3 +1,37 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
|
||||
@@ -1,3 +1,37 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!DOCTYPE doctype 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">
|
||||
|
||||
@@ -1,3 +1,37 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
|
||||
197
mozilla/js/rhino/docs/rhino15R5.html
Normal file
197
mozilla/js/rhino/docs/rhino15R5.html
Normal file
@@ -0,0 +1,197 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="Author" content="Igor Bukanov">
|
||||
<meta name="KeyWords" content="Rhino, JavaScript, Java">
|
||||
<title>Change Log</title>
|
||||
</head>
|
||||
|
||||
<body bgcolor="#ffffff">
|
||||
|
||||
<h1 align="center">
|
||||
Rhino 1.5R5 Change Log</h1>
|
||||
|
||||
This is a log of significant changes in Rhino 1.5 Release 5.
|
||||
|
||||
<h3>Wrapping of JavaScript functions as Java interfaces</h3>
|
||||
<p>
|
||||
Rhino allows to pass a JavaScript function to a Java method expecting an interface which either has a single method or all its methods have the same number of parameters and each corresponding parameter has the same type.
|
||||
The JavaScript function will be called whenever interface's method is called from Java. The function will receive all Java arguments properly converted into JS types and as the last parameter Rhino will pass interface method's name.
|
||||
</p>
|
||||
<p>
|
||||
The feature allows to simplify code that previously had to create explicit JavaAdapter objects. For example, one can write now:
|
||||
<pre>
|
||||
var button = new javax.swing.JButton("My Button");
|
||||
button.addActionListener(function(e) {
|
||||
java.lang.System.out.println("Button click:"+e);
|
||||
});
|
||||
var frame = new javax.swing.JFrame("My Frame");
|
||||
frame.addWindowListener(function(e, methodName) {
|
||||
java.lang.System.out.println("Window event:"+e);
|
||||
if (methodName == "windowClosing") {
|
||||
java.lang.System.exit(0);
|
||||
}
|
||||
});
|
||||
</pre>
|
||||
instead of
|
||||
<pre>
|
||||
var button = new javax.swing.JButton("My Button");
|
||||
button.addActionListener(new java.awt.event.WindowListener({
|
||||
windowClosing : function(e) {
|
||||
java.lang.System.out.println("Window event:"+e);
|
||||
java.lang.System.exit(0);
|
||||
},
|
||||
windowActivated : function(e) {
|
||||
java.lang.System.out.println("Window event:"+e);
|
||||
},
|
||||
// similar code for the rest of WindowListener methods
|
||||
});
|
||||
var frame = new javax.swing.JFrame("My Frame");
|
||||
frame.addWindowListener(function(e, methodName) {
|
||||
</pre>
|
||||
which was necessary in the previous version of Rhino.
|
||||
See <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=223435">Bugzilla 223435</a>.
|
||||
</p>
|
||||
|
||||
<h3>uneval() and toSource()</h3>
|
||||
<p>
|
||||
Rhino fully supports <tt>uneval()</tt> function and <tt>toSource()</tt> method which are extensions to ECMAScript available in <a href="http://www.mozilla.org/js/">SpiderMonkey</a>. They return a string that can be passed to the <tt>eval()</tt> function to reconstruct the original value when possible. It is guaranteed that <tt>uneval(eval(uneval(x))) == uneval(x)</tt> and in many cases more useful notion <tt>eval(uneval(x)) == deep_copy_of_x</tt> holds.
|
||||
</p>
|
||||
<p>
|
||||
For example, here is an extract from a <a href="shell.html">Rhino shell</a> session:
|
||||
</p>
|
||||
<pre>
|
||||
js> var x = { a: 1, b: 2, c: [1,2,3,4,5], f: function test() { return 1; }, o: { property1: "Test", proeprty2: new Date()}}
|
||||
js> uneval(x)
|
||||
({c:[1, 2, 3, 4, 5], o:{property1:"Test", proeprty2:(new Date(1076585338601))}, f:(function test() {return 1;}), a:1, b:2})
|
||||
js> x.toSource()
|
||||
({c:[1, 2, 3, 4, 5], o:{property1:"Test", proeprty2:(new Date(1076585338601))}, f:(function test() {return 1;}), a:1, b:2})
|
||||
js> uneval(x.propertyThatDoesNotExist)
|
||||
undefined
|
||||
</pre>
|
||||
<p>
|
||||
See <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=225465">Bugzilla 225465</a>.
|
||||
</p>
|
||||
|
||||
<h3>seal() and changes in semantic of sealed objects</h3>
|
||||
<p>
|
||||
Rhino supports <tt>seal(object)</tt> function which is another ECMAScript extension from SpiderMonkey. The function makes the object immune to changes and any attempt to add, modify or delete a property of such object will throw an exception. Previously sealing was only possible through the Java <tt>sealObject()</tt> method in <tt>org.mozilla.javascript.ScriptableObject</tt> and before Rhino 1.5R5 it was possible to modify existing properties of sealed objects.
|
||||
</p>
|
||||
<p>
|
||||
See <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=203013">Bugzilla 203013</a>.
|
||||
</p>
|
||||
|
||||
<h3>Exception changes</h3>
|
||||
<p>
|
||||
In Rhino 1.5R5 all exceptions generated during execution of a script provide information about script's source name and line number that triggered the exception. The exception class <tt>org.mozilla.javascript.JavaScriptException</tt> is used now only to represent exceptions explicitly thrown by the JavaScript <b>throw</b> statement, it never wraps exceptions thrown in a Java method invoked by the script. Such exceptions are always wrapped as <tt>org.mozilla.javascript.WrappedException</tt>.
|
||||
</p>
|
||||
<p>
|
||||
See <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=217584">Bugzilla 217584</a>, <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=219055">Bugzilla 219055</a>
|
||||
and <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=225817">Bugzilla 225817</a>
|
||||
</p>
|
||||
|
||||
<h3>Compiled scripts are scope independent</h3>
|
||||
<p>
|
||||
Previously Rhino required a scope object in the <tt>compileReader</tt> method of <tt>org.mozilla.javascript.Context</tt> to compile a script into <tt>org.mozilla.javascript.Script</tt> instances. Under some circumstances it was possible that the scope object would be stored in the compiled form of the script. It made impossible in such cases to reuse of the compiled form to execute the script against different scopes and lead to potential memory leaks.
|
||||
<p>
|
||||
</p>Rhino 1.5R5 fixes such misbehavior and <tt>compileReader</tt> and newly introduced <tt>compileString</tt> no longer take the scope argument. For compatibility the old form of <tt>compileReader</tt> is kept as a deprecated method.
|
||||
</p>
|
||||
<p>
|
||||
See <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=218440">Bugzilla 218440</a>.
|
||||
</p>
|
||||
|
||||
<h3>Callable interface</h3>
|
||||
<p>
|
||||
All <tt>org.mozilla.javascript.Script</tt> and <tt>org.mozilla.javascript.Function</tt> instances in Rhino now implement the new interface <tt>org.mozilla.javascript.Callable</tt> which together with the new <tt>call</tt> method in <tt>org.mozilla.javascript.Context</tt> gives a simple way to call scripts and functions without explicit calls to <tt>Context.enter()</tt> and <tt>Context.exit()</tt>.
|
||||
</p>
|
||||
<p>
|
||||
The <tt>Callable</tt> interface allows to set the value of JavaScript <b>this</b> during script execution to arbitrary <tt>org.mozilla.javascript.Scriptable</tt> instance overriding default bahaviour of using the scope object for the value of <b>this</b>.
|
||||
</p>
|
||||
<p>Rhino interpreter uses <tt>Callable</tt> to pass references to scripts and functions to <tt>org.mozilla.javascript.SecurityController</tt> directly without wrapping script code into an additional proxy <tt>Script</tt> object. It allows to optimize an implementation of <tt>callWithDomain</tt> method in <tt>org.mozilla.javascript.SecurityController</tt>.
|
||||
</p>
|
||||
<p>
|
||||
For compatibility applications extending the previous version of <tt>SecurityController</tt> are fully supported but the new applications should override <tt>callWithDomain</tt> method, not <tt>execWithDomain</tt>.
|
||||
</p>
|
||||
|
||||
<h3>No static caching</h3>
|
||||
<p>
|
||||
Rhino no longer caches generated classes and information about reflected Java classes in static objects. Instead such caches are stored in a top scope object and initialized by default during call to <tt>initStandardObjects</tt> of <tt>org.mozilla.javascript.Context</tt>. This can be overridden with the explicit call to the <tt>associate</tt> method of <tt>org.mozilla.javascript.ClassCache</tt> if cache sharing is desired.
|
||||
</p>
|
||||
<p>The cached objects no longer holds references to scope objects so even an application using multiple calls to <tt>Context.initStandardObjects</tt> and single shared <tt>ClassCache</tt> instance would not leak references to runtime library instantiations as it was the case with the previous Rhino for all applications.
|
||||
</p>
|
||||
The change allows to instantiate multiple Rhino runtime instances which would not interfere with each other and prevents memory leaks through ever growing caches. </p>
|
||||
|
||||
<h3>API for compiling scripts into class files</h3>
|
||||
<p>The new class <tt>org.mozilla.javascript.optimizer.ClassCompiler</tt> provides a simple API to compile JavaScript source into set of Java class files with the given set of compilation options. <a href="jsc.html">JavaScript Compiler</a> was upgraded to use new API and the old API were deprecated.
|
||||
</p>
|
||||
|
||||
<h3>API for Context sealing</h3>
|
||||
<p>The new methods <tt>seal(Object)</tt>, <tt>unseal(Object)</tt> and <tt>isSealed()</tt> in <tt>org.mozilla.javascript.Context</tt> allows to make <tt>Context</tt> instances immune from changes. Rhino embeddings that needs to run potentially untrusted scripts may use the new functionality to proprly implement the sandbox for such scripts without too restrictive <tt>org.mozilla.javascript.ClassShutter</tt> implementation.
|
||||
</p>
|
||||
<p>
|
||||
See <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=236117">Bugzilla 236117</a>.
|
||||
</p>
|
||||
|
||||
<h3>Optimizer generates only one class per script </h3>
|
||||
<p>
|
||||
In Rhino 1.5R5 the default optimization mode generates only one Java class for script and all its functions while previously the optimizer generated additional class for each function definition in the script. It improves loading time for scripts and decreases memory usage especially for scripts with many function definitions.
|
||||
</p>
|
||||
<p>
|
||||
See <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=198086">Bugzilla 198086</a>.
|
||||
</p>
|
||||
|
||||
<h3>Improved support for huge scripts</h3>
|
||||
<p>
|
||||
The interpreted mode contains significantly less restrictions on size and complexity of the scripts and if the remaining restrictions are not satisfied, Rhino will report an exception instead of generating corrupted internal byte code for interpreting.
|
||||
</p>
|
||||
<p>
|
||||
See <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=225831">Bugzilla 225831</a>.
|
||||
</p>
|
||||
|
||||
<h2>Resolved Bugzilla reports</h2>
|
||||
<p>
|
||||
The full list of Bugzilla reports addressed in Rhino 1.5R5 can be obtained with the following Bugzilla query:
|
||||
<br>
|
||||
<a href="http://bugzilla.mozilla.org/buglist.cgi?product=Rhino&target_milestone=1.5R5&bug_status=RESOLVED&bug_status=VERIFIED">http://bugzilla.mozilla.org/buglist.cgi?product=Rhino&target_milestone=1.5R5&bug_status=RESOLVED&bug_status=VERIFIED</a>
|
||||
<br>
|
||||
which searches <a href="http://bugzilla.mozilla.org/">bugzilla.mozilla.org</a> for all resolved or verified bugs with the product set to Rhino and the target milestone set to 1.5R5.
|
||||
</p>
|
||||
|
||||
<hr width="100%"><br>
|
||||
<a href="index.html">back to top</a></h3>
|
||||
|
||||
</body></html>
|
||||
187
mozilla/js/rhino/docs/rhino16R1.html
Normal file
187
mozilla/js/rhino/docs/rhino16R1.html
Normal file
@@ -0,0 +1,187 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="Author" content="Igor Bukanov">
|
||||
<meta name="KeyWords" content="Rhino, JavaScript, Java">
|
||||
<title>Change Log</title>
|
||||
|
||||
<style>
|
||||
P { text-align: justify; }
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body bgcolor="#ffffff">
|
||||
|
||||
<h1 align="center">
|
||||
Change Log for Rhino</h1>
|
||||
|
||||
<h2>Rhino 1.6R1, released 2004-11-29</h2>
|
||||
|
||||
<h3>Release overview</h3>
|
||||
<p>
|
||||
Rhino 1.6R1 is the new major release of Rhino. It supports ECMAScript for XML (E4X) as specified by <a href="http://www.ecma-international.org/publications/standards/Ecma-357.htm">ECMA 357</a> standard. E4X is a set of language extensions adding native XML support for JavaScript without affecting the existing code base. <a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/E4X/e4x_example.js">E4X example</a> demonstrates various E4X constructions and their usage in JavaScript code.
|
||||
</p>
|
||||
<p>
|
||||
This version of Rhino should be binary compatible with the current embeddings that use only public <a href="apidocs/index.html">API</a> unless the code use the previously deprected classes as documented <a href="#Rhino1.5R1-deprecation-removal">below</a>. Please report any incompatibility issues to <a href="http://bugzilla.mozilla.org/enter_bug.cgi?product=Rhino">Bugzilla</a>.
|
||||
</p>
|
||||
</h3>
|
||||
|
||||
<a NAME="E4X"></a>
|
||||
<h3>E4X implementation</h3>
|
||||
<p>
|
||||
The E4X code was donated to the Rhino project by <a href="http://www.bea.com/">BEA</a> and developed by staff from <a href="http://www.bea.com/">BEA</a> and <a href="http://www.agiledelta.com/">AgileDelta</a>.
|
||||
</p>
|
||||
<p>
|
||||
It uses <a href="http://xmlbeans.apache.org/">XMLBeans</a> library to implement E4X runtime. The implementation was tested against versions 1.0.2 and 1.0.3 of XMLBeans. Please make sure that <tt>xbean.jar</tt> is avaialble on the classpath if you use E4X in your scripts.
|
||||
</p>
|
||||
<p>
|
||||
See <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=242805">Bugzilla 242805</a> for details. See also <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=270779">Bugzilla 270779</a>
|
||||
for the list of known issues with E4X implementation in Rhino 1.6R1.
|
||||
</p>
|
||||
|
||||
|
||||
<h3>Other changes</h3>
|
||||
|
||||
<h4>Common root for Rhino execeptions</h4>
|
||||
<p>
|
||||
Now all Rhino execption classes are derived from <a href="apidocs/org/mozilla/javascript/RhinoException.html"><tt>org.mozilla.javascript.RhinoException</tt></a> which extends <tt>java.lang.RuntimeException</tt>.
|
||||
The class gives the uniform way to access information about the script origin of the exception and simplifies execption handling in Rhino embeddings.
|
||||
</p>
|
||||
<p>
|
||||
See <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=244492">Bugzilla 244492</a> for details.
|
||||
</p>
|
||||
|
||||
<h4>Removal of code complexity limits in the interpreter</h4>
|
||||
<p>
|
||||
The interpreter mode in Rhino does not limit any longer the script size or code complexity. It should be possible to execute any script as long as JVM resources allow so.
|
||||
</p>
|
||||
<p>
|
||||
See <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=244014">Bugzilla 244014</a> and <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=256339">Bugzilla 256339</a> for details.
|
||||
</p>
|
||||
|
||||
<h4>Tail call elimination in the interpreter</h4>
|
||||
<p>
|
||||
The interpreter mode in Rhino implements tail call elimination to avoid excessive stack space consumption when a function returns result of a call to another function.
|
||||
</p>
|
||||
<p>
|
||||
See <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=257128">Bugzilla 257128</a>.
|
||||
</p>
|
||||
|
||||
<h4>Support for continuations in the interpreter</h4>
|
||||
<p>
|
||||
The interpreter mode in Rhino supports continuations. The code is based on the ideas from the original implementation of continuations by Christopher Oliver and
|
||||
<a href="http://sisc.sourceforge.net/">SISC</a> project. To use the
|
||||
continuations make sure that the interpreter mode is selected through <a
|
||||
href="apidocs/org/mozilla/javascript/Context.html#setOptimizationLevel(int)">setting</a>
|
||||
the optimization level to -1 or by adding <tt>-opt -1</tt> to the command line
|
||||
of <a href="shell.html">Rhino shell</a>.
|
||||
</p>
|
||||
<p>
|
||||
Please note that the details of implementation and Java and JavaScript API for continuations may change in future in incompatible way.
|
||||
</p>
|
||||
<p>
|
||||
See <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=258844">Bugzilla 258844</a>.
|
||||
</p>
|
||||
|
||||
<h4>JavaImporter constructor</h4>
|
||||
<p>
|
||||
<tt>JavaImporter</tt> is a new global constructor that allows to omit explicit package names when scripting Java:
|
||||
</p>
|
||||
<pre>
|
||||
var SwingGui = JavaImporter(Packages.javax.swing,
|
||||
Packages.javax.swing.event,
|
||||
Packages.javax.swing.border,
|
||||
java.awt.event,
|
||||
java.awt.Point,
|
||||
java.awt.Rectangle,
|
||||
java.awt.Dimension);
|
||||
...
|
||||
|
||||
with (SwingGui) {
|
||||
var mybutton = new JButton(test);
|
||||
var mypoint = new Point(10, 10);
|
||||
var myframe = new JFrame();
|
||||
...
|
||||
}
|
||||
</pre>
|
||||
<p>
|
||||
Previously such functionality was available only to embeddings that used <a href="apidocs/org/mozilla/javascript/ImporterTopLevel.html"><tt>org.mozilla.javascript.ImporterTopLevel</tt></a> class as the top level scope. The class provides additional <tt>importPackage()</tt> and <tt>importClass()</tt> global functions for scripts but their extensive usage has tendency to pollute the global name space with names of Java classes and prevents loaded classes from garbage collection.
|
||||
</p>
|
||||
<p>
|
||||
See <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=245882">Bugzilla 245882</a> for details.
|
||||
</p>
|
||||
|
||||
<h4>Context customization API</h4>
|
||||
<a href="apidocs/org/mozilla/javascript/ContextFactory.html"><tt>org.mozilla.javascript.ContextFactory</tt></a> provides new API for customization of <tt>org.mozilla.javascript.Context</tt> and ensures that application-specific Context subclasses will always be used when Rhino runtime needs to create Context instances.
|
||||
</p>
|
||||
<p>
|
||||
See <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=255595">Bugzilla 245882</a> for details.
|
||||
</p>
|
||||
|
||||
<h4>Support for Date.now()</h4>
|
||||
<p>
|
||||
<tt>Date.now()</tt> function which is a SpiderMonkey extension to ECMAScript standard is available now in Rhino. The function returns number of milliseconds passed since 1970-01-01 00:00:00 UTC.
|
||||
</p>
|
||||
|
||||
|
||||
<h4><a name="Rhino1.5R1-deprecation-removal"></a>Removal of deprecated classes</h4>
|
||||
<p>
|
||||
The following classes that were deprecated in Rhino 1.5R5 are no longer available in Rhino 1.6R1:
|
||||
<ul>
|
||||
<li><tt>org.mozilla.javascript.ClassNameHelper</tt></li>
|
||||
<li><tt>org.mozilla.javascript.ClassRepository</tt></li>
|
||||
</ul>
|
||||
|
||||
See documentation for <a href="apidocs/org/mozilla/javascript/optimizer/ClassCompiler.html"><tt>org.mozilla.javascript.optimizer.ClassCompiler</tt></a> that provides replacement for ClassNameHelper and ClassRepository.
|
||||
</p>
|
||||
|
||||
<h2>Change logs for previous Rhino releases</h2>
|
||||
<ul>
|
||||
<li><a href="rhino15R5.html">Rhino 1.5R5</a></li>
|
||||
<li><a href="rhino15R41.html">Rhino 1.5R4.1</a></li>
|
||||
<li><a href="rhino15R4.html">Rhino 1.5R4</a></li>
|
||||
<li><a href="rhino15R3.html">Rhino 1.5R3</a></li>
|
||||
<li><a href="rhino15R2.html">Rhino 1.5R2</a></li>
|
||||
<li><a href="rhino15R1.html">Rhino 1.5R1</a></li>
|
||||
</ul>
|
||||
|
||||
<hr width="100%"><br>
|
||||
<a href="index.html">back to top</a></h3>
|
||||
|
||||
</body></html>
|
||||
442
mozilla/js/rhino/docs/rhino16R2.html
Normal file
442
mozilla/js/rhino/docs/rhino16R2.html
Normal file
@@ -0,0 +1,442 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
|
||||
<meta name="Author" content="Igor Bukanov">
|
||||
|
||||
<meta name="KeyWords" content="Rhino, JavaScript, Java">
|
||||
<title>Change Log</title>
|
||||
|
||||
|
||||
<style>
|
||||
P { text-align: justify; }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
|
||||
<body style="background-color: rgb(255, 255, 255);">
|
||||
|
||||
<h1 align="center">
|
||||
Change Log for Rhino</h1>
|
||||
|
||||
<h2>Rhino 1.6R2, released 2005-09-19</h2>
|
||||
|
||||
<h3>Release overview</h3>
|
||||
|
||||
<p>
|
||||
Rhino 1.6R2 is a new maintenance release of Rhino. New to Rhino 1.6Rx
|
||||
is support for ECMAScript for XML (E4X). See <a href="rhino16R2.html">Change Log for Rhino 1.6R1</a>
|
||||
for more details. </p>
|
||||
|
||||
<p>
|
||||
This version of Rhino should be binary compatible with the current
|
||||
embeddings that use only public <a href="apidocs/index.html">API</a>
|
||||
unless the code use the previously deprected classes as documented <a href="#Rhino1.5R1-deprecation-removal">below</a>.
|
||||
Please report any incompatibility issues to <a href="http://bugzilla.mozilla.org/enter_bug.cgi?product=Rhino">Bugzilla</a>.
|
||||
</p>
|
||||
|
||||
<h3>Bugs marked fixed in Rhino 1.6R2 (<a href="https://bugzilla.mozilla.org/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&product=Rhino&long_desc_type=substring&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=&keywords_type=allwords&keywords=&resolution=FIXED&emailassigned_to1=1&emailtype1=exact&email1=&emailassigned_to2=1&emailreporter2=1&emailqa_contact2=1&emailtype2=exact&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=2004-11-29&chfieldto=2005-08-21&chfield=resolution&chfieldvalue=FIXED&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=">query</a>)</h3>
|
||||
|
||||
<table x:str="" style="border-collapse: collapse; table-layout: fixed; width: 378pt;" border="0" cellpadding="0" cellspacing="0" width="504">
|
||||
|
||||
<tbody>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl24" style="height: 12.75pt; width: 48pt; font-weight: bold;" height="17" width="64">ID</td>
|
||||
|
||||
<td class="xl24" style="width: 330pt; font-weight: bold;" width="440">Summary</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=238649">238649</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Removal of deprecated features after 1.5R5</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=243057">243057</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">enhancement - ability to assign to Java function
|
||||
result a...</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=252122">252122</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">double expansion of error message</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=255595">255595</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Factory class for Context creation</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=258844">258844</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Continuation support in interpreter</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=264637">264637</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">InterpretedFunction memory footprint could be
|
||||
lighter</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=271401">271401</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">JS prototypes for superclasses with
|
||||
ScriptableObject.defi...</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=274467">274467</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Add JavaScript stack trace to exceptions</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=274996">274996</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Exceptions with multiple interpreters on stack
|
||||
may lead t...</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=277537">277537</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">isXMLName() should be properly implemented</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=277935">277935</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Assignments to descendants like "msg..s =
|
||||
something" => f...</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=278701">278701</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Minimised windows don't indicate that
|
||||
breakpoints have be...</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=280047">280047</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Not implementing Scriptable in Undefined</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=280629">280629</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">When using the debugger within another program
|
||||
the only w...</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=281067">281067</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">ThreadLocal in Context prevents class unloading</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=281247">281247</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">JDK compatibility via special class</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=281537">281537</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">ScriptRuntime.toNumber warns on Undefined</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=282447">282447</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">NPE trying to report error when trying to
|
||||
convert null to...</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=282595">282595</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Patch for BeanProperties to work with several
|
||||
setters for...</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=286251">286251</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">initFunction can be called twice</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=289294">289294</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Infinite loop during a script compilation</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=289603">289603</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Update rhino-n.tests to eliminate spidermonkey
|
||||
only tests</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=290034">290034</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Cannot catch in JavaScript the original
|
||||
exception thrown ...</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=291591">291591</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Rhino has differing behaviour to spidermonkey,
|
||||
and does n...</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=292324">292324</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">ArrayIndexOutOfBoundsException while compiling a
|
||||
script</td>
|
||||
|
||||
</tr>
|
||||
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=298786">298786</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Infinite loop when compiling with optimization</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=299539">299539</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Bad bytecode for function assignments</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=299613">299613</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Runtime support for function-results-as-lvalue</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=302501">302501</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">constructor property shouldn't be readonly</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=303572">303572</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Need access to underlying RhinoException in
|
||||
rethrown erro...</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=305323">305323</a></td>
|
||||
<td>Rhino fails to select the appropriate overloaded method</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=305753">305753</a></td>
|
||||
<td> NativeJavaMethod objects have incorrect parent when using...</td>
|
||||
</tr>
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=306258">306258</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Can not compile using Ant scripts under JDK 1.5</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=306268">306268</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Decompilation of E4X dot query is broken</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=306308">306308</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">JS function as Java interface via reflect.Proxy</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=306419">306419</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Add serialVersionUID to Serializable</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=306584">306584</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Crashes parsing .jsp page with javascripts</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=303460">303460</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Enhance Rhino's shell to execute compiled script .class f...</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=306825">306825</a></td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Allow to use shell.Global in servlets</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr style="height: 12.75pt;" height="17">
|
||||
|
||||
<td class="xl26" style="height: 12.75pt; width: 48pt; text-align: left;" x:num="" height="17" width="64"><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=309029"></a>309029</td>
|
||||
|
||||
<td class="xl25" style="width: 330pt;" width="440">Exception when evaluating recursive function</td>
|
||||
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h2>Change logs for previous Rhino releases</h2>
|
||||
|
||||
<ul>
|
||||
|
||||
<li><a href="rhino16R1.html">Rhino 1.6R1</a></li>
|
||||
|
||||
<li><a href="rhino15R5.html">Rhino 1.5R5</a></li>
|
||||
|
||||
<li><a href="rhino15R41.html">Rhino 1.5R4.1</a></li>
|
||||
|
||||
<li><a href="rhino15R4.html">Rhino 1.5R4</a></li>
|
||||
|
||||
<li><a href="rhino15R3.html">Rhino 1.5R3</a></li>
|
||||
|
||||
<li><a href="rhino15R2.html">Rhino 1.5R2</a></li>
|
||||
|
||||
<li><a href="rhino15R1.html">Rhino 1.5R1</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<hr width="100%"><br>
|
||||
|
||||
<a href="index.html">back to top</a>
|
||||
</body>
|
||||
</html>
|
||||
103
mozilla/js/rhino/docs/rhino16R3.html
Executable file
103
mozilla/js/rhino/docs/rhino16R3.html
Executable file
@@ -0,0 +1,103 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
|
||||
<meta name="Author" content="Igor Bukanov">
|
||||
|
||||
<meta name="KeyWords" content="Rhino, JavaScript, Java">
|
||||
<title>Change Log</title>
|
||||
|
||||
|
||||
<style>
|
||||
P { text-align: justify; }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
|
||||
<body style="background-color: rgb(255, 255, 255);">
|
||||
|
||||
<h1 align="center">
|
||||
Change Log for Rhino</h1>
|
||||
|
||||
<h2>Rhino 1.6R3, released 2006-07-24</h2>
|
||||
|
||||
<h3>Release overview</h3>
|
||||
|
||||
<p>
|
||||
Rhino 1.6R3 is a new maintenance release of Rhino. New to Rhino 1.6Rx
|
||||
is support for ECMAScript for XML (E4X). See <a href="rhino16R2.html">Change Log for Rhino 1.6R1</a>
|
||||
for more details. </p>
|
||||
|
||||
<p>
|
||||
This version of Rhino should be binary compatible with the current
|
||||
embeddings that use only public <a href="apidocs/index.html">API</a>
|
||||
unless the code use the previously deperected classes as documented <a href="#Rhino1.5R1-deprecation-removal">below</a>.
|
||||
Please report any incompatibilitiy issues to <a href="http://bugzilla.mozilla.org/enter_bug.cgi?product=Rhino">Bugzilla</a>.
|
||||
</p>
|
||||
|
||||
<h3>Bugs marked fixed in Rhino 1.6R3 (<a href="https://bugzilla.mozilla.org/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&product=Rhino&long_desc_type=substring&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=&keywords_type=allwords&keywords=&resolution=FIXED&emailassigned_to1=1&emailtype1=exact&email1=&emailassigned_to2=1&emailreporter2=1&emailqa_contact2=1&emailtype2=exact&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=2005-08-22&chfieldto=2006-07-24&chfield=resolution&chfieldvalue=FIXED&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=">query</a>)</h3>
|
||||
|
||||
|
||||
<h2>Change logs for previous Rhino releases</h2>
|
||||
|
||||
<ul>
|
||||
|
||||
<li><a href="rhino16R2.html">Rhino 1.6R2</a></li>
|
||||
|
||||
<li><a href="rhino16R1.html">Rhino 1.6R1</a></li>
|
||||
|
||||
<li><a href="rhino15R5.html">Rhino 1.5R5</a></li>
|
||||
|
||||
<li><a href="rhino15R41.html">Rhino 1.5R4.1</a></li>
|
||||
|
||||
<li><a href="rhino15R4.html">Rhino 1.5R4</a></li>
|
||||
|
||||
<li><a href="rhino15R3.html">Rhino 1.5R3</a></li>
|
||||
|
||||
<li><a href="rhino15R2.html">Rhino 1.5R2</a></li>
|
||||
|
||||
<li><a href="rhino15R1.html">Rhino 1.5R1</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<hr width="100%"><br>
|
||||
|
||||
<a href="index.html">back to top</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,3 +1,37 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
@@ -97,7 +131,7 @@ numeric identifiers. Conceptually, all accessors are converted to strings
|
||||
in order to perform the lookup of the property in the object. However,
|
||||
this is not the implementation used in practice because a number to string
|
||||
conversion is too expensive to be performed on every array access.
|
||||
<p>Instead, every property accessor method in <a href="org/mozilla/javascript/Scriptable.html">Scriptable</a>
|
||||
<p>Instead, every property accessor method in <a href="apidocs/org/mozilla/javascript/Scriptable.html">Scriptable</a>
|
||||
(<tt>has</tt>, <tt>get</tt>, <tt>set</tt>, <tt>remove</tt>, <tt>getAttributes</tt>,
|
||||
and <tt>setAttributes</tt>) has overloaded forms that take either a <tt>String</tt>
|
||||
or an <tt>int</tt> argument. It is the responsibility of the caller to
|
||||
@@ -113,14 +147,14 @@ Defining Host Objects</h3>
|
||||
Host objects are JavaScript objects that provide special access to the
|
||||
host environment. For example, in a browser environment, the Window and
|
||||
Document objects are host objects.
|
||||
<p>The easiest way to define new host objects is by using <a href="org/mozilla/javascript/ScriptableObject.html#defineClass(org.mozilla.javascript.Scriptable, java.lang.Class)">ScriptableObject.defineClass()</a>.
|
||||
<p>The easiest way to define new host objects is by using <a href="apidocs/org/mozilla/javascript/ScriptableObject.html#defineClass(org.mozilla.javascript.Scriptable, java.lang.Class)">ScriptableObject.defineClass()</a>.
|
||||
This method defines a set of JavaScript objects using a Java class. Several
|
||||
of the <a href="examples.html">examples</a> define host objects this way.
|
||||
<p>If the services provided by defineClass are insufficient, try other
|
||||
methods of
|
||||
<a href="org/mozilla/javascript/ScriptableObject.html">ScriptableObject</a>
|
||||
<a href="apidocs/org/mozilla/javascript/ScriptableObject.html">ScriptableObject</a>
|
||||
and
|
||||
<a href="org/mozilla/javascript/FunctionObject.html">FunctionObject</a>,
|
||||
<a href="apidocs/org/mozilla/javascript/FunctionObject.html">FunctionObject</a>,
|
||||
such as <tt>defineProperty</tt> and <tt>defineFunctionProperties</tt>.
|
||||
<br>
|
||||
<br>
|
||||
|
||||
@@ -1,3 +1,37 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
@@ -158,9 +192,8 @@ JavaScript use <i>static scope</i>, which means that variables are first looked
|
||||
up in the function and then, if not found there, in the lexically enclosing
|
||||
scope. This causes problems if functions you define in your shared scope
|
||||
need access to variables you define in your instance scope.
|
||||
<p>With Rhino 1.5, it is possible to compile functions to use <i>dynamic
|
||||
scope</i>. With dynamic scope, functions look at the top-level scope of the
|
||||
calling function rather than their lexical scope. So we can store information
|
||||
<p>With Rhino 1.6, it is possible to use <i>dynamic scope</i>. With dynamic scope, functions look at the top-level scope of the currently executed script
|
||||
rather than their lexical scope. So we can store information
|
||||
that varies across scopes in the instance scope yet still share functions
|
||||
that manipulate that information reside in the shared scope. </p>
|
||||
<p>The <a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/DynamicScopes.java">
|
||||
|
||||
@@ -1,68 +1,110 @@
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!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.7 [en] (WinNT; U) [Netscape]">
|
||||
<meta name="KeyWords" content="Rhino, JavaScript, Java">
|
||||
<title>Scripting Java</title>
|
||||
|
||||
<link rel="up" href="./" title="Rhino project page">
|
||||
<link rel="section" href="#rhinoshell" title="Rhino Shell">
|
||||
<link rel="section" href="#liveconnect" title="LiveConnect">
|
||||
<link rel="section" href="#accessing" title="Accessing JavaBean">
|
||||
<link rel="section" href="#importingclasses" title="Importing classes & packages">
|
||||
<link rel="section" href="#extending" title="Extending Java Classes">
|
||||
<link rel="section" href="#javaadapter" title="JavaAdapter constructor">
|
||||
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF">
|
||||
<script src="owner.js"></script>
|
||||
<body>
|
||||
|
||||
<center>
|
||||
<h1>
|
||||
Scripting Java</h1></center>
|
||||
<script>document.write(owner());</script>
|
||||
<p class="crumbs"><em>You are here:</em> <a href="./">Rhino project page</a> > <strong>Scripting Java</strong></p>
|
||||
|
||||
<br><script>
|
||||
var d = new Date(document.lastModified);
|
||||
document.write((d.getMonth()+1)+"/"+d.getDate()+"/"+d.getFullYear());
|
||||
document.write('<br>');
|
||||
</script>
|
||||
|
||||
<center>
|
||||
<hr WIDTH="100%"></center>
|
||||
<h1 style="text-align: center;">Scripting Java</h1>
|
||||
<address class="author">Norris Boyd</address>
|
||||
|
||||
<p>It's possible to use Rhino just for scripting Java. You don't have to
|
||||
write any additional Java code; just use the existing Rhino shell and then
|
||||
make calls into Java.
|
||||
<br>
|
||||
<h2>
|
||||
Rhino Shell</h2>
|
||||
The Rhino shell allows you to run scripts from files or interactively at
|
||||
a command line.
|
||||
make calls into Java.</p>
|
||||
|
||||
<h2><a name="rhinoshell" id="rhinoshell">Rhino Shell</a></h2>
|
||||
<p>The Rhino shell allows you to run scripts from files or interactively at
|
||||
a command line.</p>
|
||||
<p>If you download the zip file for rhino, it will contain a single JAR
|
||||
file, <tt>js.jar</tt>. If you add the JAR file to your class path, you
|
||||
can start the Rhino shell using the command
|
||||
<pre> java org.mozilla.javascript.tools.shell.Main</pre>
|
||||
or if you have Java 2 (JDK 1.2 or greater), you can avoid changing your classpath
|
||||
and simply use the command
|
||||
<pre> java -jar js.jar</pre>
|
||||
Unfortunately the <tt>-jar</tt> option to <tt>java</tt> will overwrite
|
||||
your existing classpath. The shell's interactive mode is a good way to
|
||||
begin exploring Rhino.
|
||||
<p><i>Note: Earlier versions of Rhino have two JAR files, js.jar and jstools.jar,
|
||||
and don't support the -jar option. Both JAR files must be added to the
|
||||
class path to start the shell</i>.
|
||||
file, <code class="filename">js.jar</code>. If you add the JAR file to
|
||||
your class path, you can start the Rhino shell using the command</p>
|
||||
|
||||
<pre class="code"> java org.mozilla.javascript.tools.shell.Main
|
||||
</pre>
|
||||
|
||||
<p>or if you have Java 2 (JDK 1.2 or greater), you can avoid changing your
|
||||
classpath and simply use the command</p>
|
||||
|
||||
<pre class="code"> java -jar js.jar</pre>
|
||||
|
||||
<p>Unfortunately the <code>-jar</code> option to <code class="command">java</code>
|
||||
will overwrite your existing classpath. The shell's interactive mode
|
||||
is a good way to begin exploring Rhino.</p>
|
||||
<p class="note">Earlier versions of Rhino have two JAR files, js.jar and
|
||||
jstools.jar, and don't support the -jar option. Both JAR files must be
|
||||
added to the class path to start the shell.</p>
|
||||
<p>You can execute a JavaScript file by putting the file name as an argument
|
||||
to the shell class:
|
||||
<pre> java org.mozilla.javascript.tools.shell.Main myScript.js</pre>
|
||||
There are a number of options for evaluating scripts using the shell. See
|
||||
the <a href="http://www.mozilla.org/rhino/shell.html">command description</a>
|
||||
for more information.
|
||||
<br>
|
||||
<h2>
|
||||
LiveConnect: Communicating with Java from JavaScript</h2>
|
||||
If you are planning to script Java using Rhino, you'll want to use LiveConnect,
|
||||
which allows you to create Java classes and call Java methods from within
|
||||
JavaScript. For example, here's a log from an interactive session. If you
|
||||
type it in, you'll see a window with a button filling it.
|
||||
<center>
|
||||
<p><img SRC="scriptjavaframe.jpg" height=100 width=200>
|
||||
<br><i><font size=-1>A Java frame created from the Rhino shell.</font></i></center>
|
||||
to the shell class:</p>
|
||||
<pre> java org.mozilla.javascript.tools.shell.Main myScript.js</pre>
|
||||
<p>There are a number of options for evaluating scripts using the shell. See
|
||||
the <a href="shell.html">command description</a> for more information.</p>
|
||||
|
||||
<pre>$ java org.mozilla.javascript.tools.shell.Main
|
||||
<h2><a name="liveconnect" id="liveconnect">LiveConnect: Communicating with Java
|
||||
from JavaScript</a></h2>
|
||||
<p>If you are planning to script Java using Rhino, you'll want to use
|
||||
LiveConnect, which allows you to create Java classes and call Java methods
|
||||
from within JavaScript. For example, here's a log from an interactive session.
|
||||
If you type it in, you'll see a window with a button filling it.</p>
|
||||
|
||||
<div class="figure" style="text-align: center;"><img src="scriptjavaframe.jpg" height="100" width="200" alt=""><br>
|
||||
A Java frame created from the Rhino shell.</div>
|
||||
|
||||
<pre class="code">
|
||||
$ java org.mozilla.javascript.tools.shell.Main
|
||||
js> importPackage(java.awt);
|
||||
js> frame = new Frame("JavaScript")
|
||||
java.awt.Frame[frame0,0,0,0x0,invalid,hidden,layout=java.awt.BorderLayout,resizable,title=JavaScript]
|
||||
@@ -74,146 +116,190 @@ js> frame.add(button)
|
||||
java.awt.Button[button0,0,0,0x0,invalid,label=OK]
|
||||
js> frame.show()
|
||||
js> quit()
|
||||
$</pre>
|
||||
If you wish to load classes from JavaScript that aren't in the <tt>java</tt>
|
||||
package, you'll need to prefix the package name with "<tt>Packages.</tt>".
|
||||
For example:
|
||||
<pre>$ java org.mozilla.javascript.tools.shell.Main
|
||||
js> cx = Packages.org.mozilla.javascript.Context.enter()
|
||||
$
|
||||
</pre>
|
||||
|
||||
<p>If you wish to load classes from JavaScript that aren't in the
|
||||
<code>java</code> package, you'll need to prefix the package name
|
||||
with "<code>Packages.</code>". For example:</p>
|
||||
|
||||
<pre class="code">
|
||||
$ java org.mozilla.javascript.tools.shell.Main
|
||||
js> cx = Packages.org.mozilla.javascript.Context.currentContext
|
||||
org.mozilla.javascript.Context@25980b44
|
||||
js> cx.evaluateString(this, "3+2", null, 0, null)
|
||||
js> cx.evaluateString(this, "3+2", null, 0, null)
|
||||
5.0
|
||||
js> quit()
|
||||
$</pre>
|
||||
js> quit()
|
||||
$
|
||||
</pre>
|
||||
|
||||
<h2>
|
||||
Accessing JavaBean Properties</h2>
|
||||
Java classes can define JavaBean properties using getter and setter methods.
|
||||
For example, the following class defines two properties:
|
||||
<p><tt>public class Me {</tt>
|
||||
<br><tt> public int getAge() { return age; }</tt>
|
||||
<br><tt> public void setAge(int anAge) { age = anAge;
|
||||
}</tt>
|
||||
<br><tt> public String getSex() { return "male"; }</tt>
|
||||
<br><tt> private int age;</tt>
|
||||
<br><tt>};</tt>
|
||||
<p>The two properties defined are <i>age</i> and <i>sex</i>. The <i>sex</i>
|
||||
property is read-only: it has no setter.
|
||||
<p>Using Rhino we can access the bean properties as if they where JavaScript
|
||||
properties. We can also continue to call the methods that define the property.
|
||||
<p><tt>js> me = new Packages.Me();</tt>
|
||||
<br><tt>Me@93</tt>
|
||||
<br><tt>js> me.getSex()</tt>
|
||||
<br><tt>male</tt>
|
||||
<br><tt>js> me.sex</tt>
|
||||
<br><tt>male</tt>
|
||||
<br><tt>js> me.age = 33;</tt>
|
||||
<br><tt>33</tt>
|
||||
<br><tt>js> me.age</tt>
|
||||
<br><tt>33</tt>
|
||||
<br><tt>js> me.getAge()</tt>
|
||||
<br><tt>33</tt>
|
||||
<br><tt>js></tt>
|
||||
<p>Since the <i>sex</i> property is read-only, we are not allowed to write
|
||||
to it.
|
||||
<p><i>Note: JavaBean reflection is not available in versions of Rhino before
|
||||
1.5.</i>
|
||||
<br><tt></tt>
|
||||
<h2>
|
||||
Importing Java Classes and Packages</h2>
|
||||
Above we saw the use of the <tt>importPackage</tt> function to import all
|
||||
the classes from a particular Java package. There is also <tt>importClass</tt>,
|
||||
which imports a single class:
|
||||
<pre>$ java org.mozilla.javascript.tools.shell.Main
|
||||
js> importClass(Packages.org.mozilla.javascript.Context)
|
||||
js> cx = Context.enter()
|
||||
<h2><a name="accessing" id="accessing">Accessing JavaBean Properties</a></h2>
|
||||
<p>Java classes can define JavaBean properties using getter and setter methods.
|
||||
For example, the following class defines two properties:</p>
|
||||
|
||||
<pre class="code">
|
||||
public class Me {
|
||||
public int getAge() { return age; }
|
||||
public void setAge(int anAge) { age = anAge;
|
||||
}
|
||||
public String getSex() { return "male"; }
|
||||
private int age;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<p>The two properties defined are <var>age</var> and <var>sex</var>.
|
||||
The <var>sex</var> property is read-only: it has no setter.</p>
|
||||
|
||||
<p>Using Rhino we can access the bean properties as if they where
|
||||
JavaScript properties. We can also continue to call the methods that
|
||||
define the property.</p>
|
||||
|
||||
<pre class="code">
|
||||
js> me = new Packages.Me();
|
||||
Me@93
|
||||
js> me.getSex()
|
||||
male
|
||||
js> me.sex
|
||||
male
|
||||
js> me.age = 33;
|
||||
33
|
||||
js> me.age
|
||||
33
|
||||
js> me.getAge()
|
||||
33
|
||||
js>
|
||||
</pre>
|
||||
|
||||
<p>Since the <var>sex</var> property is read-only, we are not allowed to write
|
||||
to it.</p>
|
||||
<p class="note">JavaBean reflection is not available in versions of Rhino before
|
||||
1.5.</p>
|
||||
|
||||
<h2><a name="importingclasses" id="importingclasses">Importing Java Classes
|
||||
and Packages</a></h2>
|
||||
<p>Above we saw the use of the <code>importPackage</code> function
|
||||
to import all the classes from a particular Java package. There is
|
||||
also <code>importClass</code>, which imports a single class:</p>
|
||||
|
||||
<pre class="code">
|
||||
$ java org.mozilla.javascript.tools.shell.Main
|
||||
js> importClass(Packages.org.mozilla.javascript.Context)
|
||||
js> cx = Context.enter()
|
||||
org.mozilla.javascript.Context@25980d62
|
||||
js> cx.evaluateString(this, "3+2", null, 0, null)
|
||||
js> cx.evaluateString(this, "3+2", null, 0, null)
|
||||
5.0
|
||||
js> quit()
|
||||
$</pre>
|
||||
js> quit()
|
||||
$
|
||||
</pre>
|
||||
|
||||
<h2>
|
||||
Extending Java Classes and Implementing Java Interfaces with JavaScript</h2>
|
||||
Starting from the example above of creating a Java frame using JavaScript,
|
||||
we can add a listener for the button. Once we call <tt>addActionListener</tt>
|
||||
we can then click on the button to get the current date printed out:
|
||||
<pre>$ java org.mozilla.javascript.tools.shell.Main
|
||||
js> importPackage(java.awt);
|
||||
js> frame = new Frame("JavaScript")
|
||||
<h2><a name="extending" id="extending">Extending Java Classes and
|
||||
Implementing Java Interfaces with JavaScript</a></h2>
|
||||
|
||||
<p>Starting from the example above of creating a Java frame using JavaScript,
|
||||
we can add a listener for the button. Once we call <code>addActionListener</code>
|
||||
we can then click on the button to get the current date printed out:</p>
|
||||
|
||||
<pre class="code">
|
||||
$ java org.mozilla.javascript.tools.shell.Main
|
||||
js> importPackage(java.awt);
|
||||
js> frame = new Frame("JavaScript")
|
||||
java.awt.Frame[frame0,0,0,0x0,invalid,hidden,layout=java.awt.BorderLayout,resizable,title=JavaScript]
|
||||
js> button = new Button("OK")
|
||||
js> button = new Button("OK")
|
||||
java.awt.Button[button0,0,0,0x0,invalid,label=OK]
|
||||
js> frame.setSize(new Dimension(200,100))
|
||||
js> frame.add(button)
|
||||
js> frame.setSize(new Dimension(200,100))
|
||||
js> frame.add(button)
|
||||
java.awt.Button[button0,0,0,0x0,invalid,label=OK]
|
||||
js> frame.show()
|
||||
js> function printDate() { print(new Date()) }
|
||||
js> printDate()
|
||||
js> frame.show()
|
||||
js> function printDate() { print(new Date()) }
|
||||
js> printDate()
|
||||
Wed Mar 15 15:42:20 GMT-0800 (PST) 2000
|
||||
js> o = { actionPerformed: printDate }
|
||||
js> o = { actionPerformed: printDate }
|
||||
[object Object]
|
||||
js> o.actionPerformed()
|
||||
js> o.actionPerformed()
|
||||
Wed Mar 15 15:42:39 GMT-0800 (PST) 2000
|
||||
js> buttonListener = java.awt.event.ActionListener(o)
|
||||
js> buttonListener = java.awt.event.ActionListener(o)
|
||||
adapter0@6acc0f66
|
||||
js> button.addActionListener(buttonListener)
|
||||
js> Wed Mar 15 15:43:05 GMT-0800 (PST) 2000
|
||||
js> button.addActionListener(buttonListener)
|
||||
js> Wed Mar 15 15:43:05 GMT-0800 (PST) 2000
|
||||
Wed Mar 15 15:43:05 GMT-0800 (PST) 2000
|
||||
Wed Mar 15 15:43:08 GMT-0800 (PST) 2000
|
||||
quit()
|
||||
$</pre>
|
||||
When we type <tt>buttonListener = java.awt.event.ActionListener(o)</tt>,
|
||||
Rhino actually creates a new Java class that implements <tt>ActionListener</tt>
|
||||
and forwards calls from that class to the JavaScript object. So when you
|
||||
click on the button, the <tt>printDate</tt> method is called.
|
||||
<p>
|
||||
Starting from the release 1.5R5 Rhino allows to pass JavaScript functions directly to Java methods if the corresponding argument is Java interface with single method. It allows to pass <tt>printDate</tt> directly to <tt>addActionListener</tt> and simplifies example:
|
||||
<pre>$ java org.mozilla.javascript.tools.shell.Main
|
||||
js> importPackage(java.awt);
|
||||
js> frame = new Frame("JavaScript")
|
||||
$
|
||||
</pre>
|
||||
|
||||
<p>When we type
|
||||
<code class="command">buttonListener = java.awt.event.ActionListener(o)</code>,
|
||||
Rhino actually creates a new Java class that implements
|
||||
<code>ActionListener</code> and forwards calls from that class to
|
||||
the JavaScript object. So when you click on the button, the
|
||||
<code>printDate</code> method is called.</p>
|
||||
|
||||
<p>Starting from the release 1.5R5 Rhino allows to pass
|
||||
JavaScript functions directly to Java methods if the corresponding
|
||||
argument is Java interface and it either has the single method
|
||||
or all its methods has the same number of arguments and
|
||||
corresponding arguments has the same types. It allows to pass
|
||||
<code>printDate</code> directly to <code>addActionListener</code>
|
||||
and simplifies example:</p>
|
||||
|
||||
<pre class="code">
|
||||
$ java org.mozilla.javascript.tools.shell.Main
|
||||
js> importPackage(java.awt);
|
||||
js> frame = new Frame("JavaScript")
|
||||
java.awt.Frame[frame0,0,0,0x0,invalid,hidden,layout=java.awt.BorderLayout,title=JavaScript,resizable,normal]
|
||||
js> button = new Button("OK")
|
||||
js> button = new Button("OK")
|
||||
java.awt.Button[button0,0,0,0x0,invalid,label=OK]
|
||||
js> frame.setSize(new Dimension(200,100))
|
||||
js> frame.add(button)
|
||||
js> frame.setSize(new Dimension(200,100))
|
||||
js> frame.add(button)
|
||||
java.awt.Button[button0,0,0,0x0,invalid,label=OK]
|
||||
js> frame.show()
|
||||
js> function printDate() { print(new Date()) }
|
||||
js> printDate()
|
||||
js> function printDate() { print(new Date()) }
|
||||
js> printDate()
|
||||
Mon Oct 27 2003 10:35:44 GMT+0100 (CET)
|
||||
js> button.addActionListener(printDate)
|
||||
js> Mon Oct 27 2003 10:36:09 GMT+0100 (CET)
|
||||
js> button.addActionListener(printDate)
|
||||
js> Mon Oct 27 2003 10:36:09 GMT+0100 (CET)
|
||||
Mon Oct 27 2003 10:36:10 GMT+0100 (CET)
|
||||
quit()
|
||||
$</pre>
|
||||
$
|
||||
</pre>
|
||||
|
||||
<h2>
|
||||
JavaAdapter constructor</h2>
|
||||
Another way to create a JavaAdapter is to call the JavaAdapter constructor
|
||||
<h2><a name="javaadapter" id="javaadapter">JavaAdapter constructor</a></h2>
|
||||
|
||||
<p>Another way to create a JavaAdapter is to call the JavaAdapter constructor
|
||||
explicitly. Using the JavaAdapter constructor gives you additional features
|
||||
that cannot be had by "constructing" a Java interface as was done above.
|
||||
<p>Instead of writing
|
||||
<pre> buttonListener = java.awt.event.ActionListener(o)</pre>
|
||||
above we can also write
|
||||
<pre> buttonListener = new JavaAdapter(java.awt.event.ActionListener, o)</pre>
|
||||
which is equivalent. If we also wanted to extend class <tt>Foo</tt>, while
|
||||
also implementing <tt>java.lang.Runnable</tt>, we would write
|
||||
<pre> buttonListener = new JavaAdapter(Packages.Foo,
|
||||
java.awt.event.ActionListener,
|
||||
java.lang.Runnable, o)</pre>
|
||||
In general the syntax is
|
||||
<p> <tt>new JavaAdapter(</tt><i>java-class</i>, [<i>java-class</i>,
|
||||
...] <i>javascript-object</i><tt>)</tt>
|
||||
<p>where at most one <i>java-class</i> is a Java class and the remaining
|
||||
<i>java-class</i>es
|
||||
are interfaces. The result will be a Java adapter that extends any specified
|
||||
Java class, implements the Java interfaces, and forwards any calls to the
|
||||
methods of the <i>javascript-object</i>.
|
||||
<h3>
|
||||
that cannot be had by "constructing" a Java interface as was done above.</p>
|
||||
|
||||
<hr WIDTH="100%"><br>
|
||||
<a href="index.html">back to top</a></h3>
|
||||
<p>Instead of writing</p>
|
||||
|
||||
<pre class="code">buttonListener = java.awt.event.ActionListener(o)
|
||||
</pre>
|
||||
|
||||
<p>above we can also write</p>
|
||||
|
||||
<pre class="code">
|
||||
buttonListener = new JavaAdapter(java.awt.event.ActionListener, o)
|
||||
</pre>
|
||||
|
||||
<p>which is equivalent. If we also wanted to extend class <code>Foo</code>,
|
||||
while also implementing <code>java.lang.Runnable</code>, we would write</p>
|
||||
|
||||
<pre class="code">
|
||||
buttonListener = new JavaAdapter(Packages.Foo,
|
||||
java.awt.event.ActionListener,
|
||||
java.lang.Runnable, o)
|
||||
</pre>
|
||||
|
||||
<p>In general the syntax is</p>
|
||||
|
||||
<pre class="code">
|
||||
new JavaAdapter(<var>java-class</var>, [<var>java-class</var>,...] <var>javascript-object</var>)
|
||||
</pre>
|
||||
|
||||
<p>where at most one <code>java-class</code> is a Java class and the
|
||||
remaining <code>java-class</code>es are interfaces. The result will be
|
||||
a Java adapter that extends any specified Java class, implements the
|
||||
Java interfaces, and forwards any calls to the methods of the
|
||||
<i>javascript-object</i>.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,3 +1,37 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
|
||||
@@ -1,3 +1,37 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
@@ -18,21 +52,40 @@ Invoking the Shell</h2>
|
||||
<tt>java org.mozilla.javascript.tools.shell.Main [<i>options</i>]
|
||||
<i>script-filename-or-url</i> [<i>script-arguments</i>]</tt>
|
||||
<p>where <tt><i>options</i></tt> are:
|
||||
<p><tt>-e <i>script-source</i></tt>
|
||||
<p>
|
||||
|
||||
<tt>-e <i>script-source</i></tt>
|
||||
<blockquote>Executes <i>script-source</i> as a JavaScript script.</blockquote>
|
||||
<tt>-f <i>script-filename-or-url</i></tt>
|
||||
<blockquote>Reads <i>script-filename-or-url</i> content and execute it as a JavaScript script.</blockquote>
|
||||
|
||||
<tt>-opt <i>optLevel</i></tt>
|
||||
<br><tt>-O <i>optLevel</i></tt>
|
||||
<ul>Optimizes at level <i>optLevel</i>, which must be an integer between
|
||||
0 and 9. See <a href="opt.html">Optimization</a> for more details.</ul>
|
||||
<blockquote>
|
||||
Optimizes at level <i>optLevel</i>, which must be an integer between
|
||||
0 and 9. See <a href="opt.html">Optimization</a> for more details.
|
||||
</blockquote>
|
||||
|
||||
<tt>-version <i>versionNumber</i></tt>
|
||||
<ul>Specifies the language version to compile with. The string <i>versionNumber</i>
|
||||
<blockquote>
|
||||
Specifies the language version to compile with. The string <i>versionNumber</i>
|
||||
must be one of <tt>100</tt>, <tt>110</tt>, <tt>120</tt>, <tt>130</tt>,
|
||||
or <tt>140</tt>. See <a href="overview.html#versions">JavaScript Language
|
||||
Versions</a> for more information on language versions.</ul>
|
||||
Versions</a> for more information on language versions.
|
||||
</blockquote>
|
||||
|
||||
<tt>-strict</tt>
|
||||
<blockquote>
|
||||
Enable strict mode.
|
||||
</blockquote>
|
||||
|
||||
<tt>-continuations</tt>
|
||||
<blockquote>
|
||||
Enable experiments support for continuations and set the optimization level to -1 to force interpretation mode.
|
||||
</blockquote>
|
||||
|
||||
If the shell is invoked with the system property rhino.use_java_policy_security set to true and with a security manager installed, the shell restricts scripts permissions based on their URLs according to Java policy settings. This is available only if JVM implements Java2 security model.
|
||||
|
||||
<h2>
|
||||
Predefined Properties</h2>
|
||||
Scripts executing in the shell have access to some additional properties
|
||||
@@ -100,6 +153,10 @@ runCommand(<i>commandName</i>, [<i>arg</i>, ...] [<i>options</i>])</h4>
|
||||
<blockquote>Execute the specified command with the given argument and options
|
||||
as a separate process and return the exit status of the process. For details, see JavaDoc for <a href="http://lxr.mozilla.org/mozilla/source/js/rhino/toolsrc/org/mozilla/javascript/tools/shell/Global.java">org.mozilla.javascript.tools.shell.Global#runCommand</a>.</blockquote>
|
||||
|
||||
<h4>
|
||||
seal(<i>object</i>)</h4>
|
||||
<blockquote>Seal the specified object so any attempt to add, delete or modify its properties would throw an exception.</blockquote>
|
||||
|
||||
<h4>
|
||||
serialize(<i>object</i>, <i>filename</i>)</h4>
|
||||
<blockquote>Serialize the given object to the specified file.</blockquote>
|
||||
@@ -225,9 +282,26 @@ js> runCommand("echo", { args: arg_array})
|
||||
1 2 3 4
|
||||
0
|
||||
</pre>
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
Examples for Windows are similar:
|
||||
<pre>
|
||||
js> // Invoke shell command
|
||||
js> runCommand("cmd", "/C", "date /T")
|
||||
27.08.2005
|
||||
0
|
||||
js> // Run sort collectiong the output
|
||||
js> var opt={input: "c\na\nb", output: 'Sort Output:\n'}
|
||||
js> runCommand("sort", opt)
|
||||
0
|
||||
js> print(opt.output)
|
||||
Sort Output:
|
||||
a
|
||||
b
|
||||
c
|
||||
js> // Invoke notepad and wait until it exits
|
||||
js> runCommand("notepad")
|
||||
0
|
||||
</pre>
|
||||
<hr WIDTH="100%">
|
||||
<br><a href="index.html">back to top</a>
|
||||
</body>
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
<!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.7 [en]C-NSCP (WinNT; U) [Netscape]">
|
||||
<title>JavaScript Tools</title>
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF">
|
||||
|
||||
<center>
|
||||
<h1>
|
||||
JavaScript Tools</h1></center>
|
||||
|
||||
<h2>
|
||||
JavaScript shell</h2>
|
||||
The <a href="shell.html">JavaScript shell</a> allows for interactive and
|
||||
batch execution of JavaScript scripts.
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<h2>
|
||||
JavaScript compiler</h2>
|
||||
The <a href="jsc.html">JavaScript compiler</a> translates JavaScript source
|
||||
into Java class files.
|
||||
<br>
|
||||
<p>
|
||||
<hr WIDTH="100%">
|
||||
<br><a href="index.html">back to top</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,3 +1,37 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
@@ -210,9 +244,8 @@ hi</font></pre>
|
||||
<p>The next example is <a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/RunScript2.java">RunScript2</a>.
|
||||
This is the same as RunScript, but with the addition of two extra lines
|
||||
of code:
|
||||
<dir><tt><font color="#006600">Scriptable jsArgs = Context.toObject(System.out,
|
||||
scope);</font></tt>
|
||||
<br><tt><font color="#006600">scope.put("out", scope, jsArgs);</font></tt></dir>
|
||||
<dir><tt><font color="#006600">Object wrappedOut = Context.javaToJS(System.out, scope);</font></tt>
|
||||
<br><tt><font color="#006600">ScriptableObject.putProperty(scope, "out", wrappedOut);</font></tt></dir>
|
||||
These lines add a global variable <tt>out</tt> that is a JavaScript reflection
|
||||
of the <tt>System.out</tt> variable:
|
||||
<dir><tt><font color="#663366">$ java RunScript2 'out.println(42)'</font></tt>
|
||||
|
||||
@@ -16,8 +16,8 @@ How are people using Rhino?</h1></center>
|
||||
Here's a partial list of the ways people are using Rhino in their projects.
|
||||
The initial list was collected by Netscape marketing, so Rhino is referred
|
||||
to as Netscape Java-based JavaScript. We'd love to hear how you're using
|
||||
Rhino--just mail <script>document.write(owner());</script>
|
||||
.
|
||||
Rhino--just mail <script>document.write(owner());</script>.
|
||||
|
||||
<p><a href="http://www.attachmate.com">Attachmate</a>
|
||||
<br>"Netscape JavaScript 1.5 with Java implementation was a perfect solution
|
||||
for developing our MacroRecorder because it made our development process
|
||||
@@ -29,6 +29,11 @@ thin clients, called e-Vantage Viewers. The Netscape Java-based JavaScript
|
||||
interpreter is used in a MacroRecorder feature that allows browser-based
|
||||
users to efficiently navigate host applications on mainframe and midrange
|
||||
systems.
|
||||
|
||||
<p><a href="http://www.avivasolutions.com/">Aviva Solutions</a>
|
||||
<br>
|
||||
Aviva for Java is a mainframe connectivity product. To overcome the limitations of the arcane mainframe user interface, it is customary to provide scripting capabilities in such products, so that repetitive user actions can be automated. Aviva for Java is a Java applet. As such, its size, security and compatibility requirements are strict. Rhino has been found to be the perfect scripting engine: pure Java, works perfectly in an applet environment, regardless of the VM vendor or version, it is light and in the same time very powerful. JavaScript as the scripting language makes perfect sense in a browser environment.
|
||||
|
||||
<p><a href="http://www.bristowhill.com/">Bristow Hill Software</a>
|
||||
<br>"We thought it would require lots of work to add scripting capability
|
||||
to Bristow Hill Server Pages, but we were delighted to find that Netscape
|
||||
@@ -39,30 +44,60 @@ and compile it down to Java classes which could be used directly for greater
|
||||
speed in production. Netscape's JavaScript engine is rock solid and standards
|
||||
compliant, and my only regret is that we didn't start using it sooner,"
|
||||
said Don Anderson, President of Bristow Hill Software.
|
||||
|
||||
<p><a href="http://www.celcorp.com/webrecorder.html">Celware WebRecorder</a>
|
||||
<br>WebRecorder allows developers and analysts to quickly and easily automate Web navigation and data extraction from Web pages. Users can model and parameterize navigations and extractions, then wrap them in business processes for execution from a client application. Scripting via Rhino allows users to create the business logic in these processes. It also allows their processes to integrate Web access with any other kind of system or data the Java platform can reach.
|
||||
|
||||
<p><a href="http://www.discoverymachine.com">Discovery Machine</a>
|
||||
<br>Discovery Machine's Expertise Encoding and Execution Workshop (E3W) allows experts to easily and seamlessly encode their knowledge and processes into immediately usable, executable graphical software that can then be shared, modified, and leveraged. In this environment, knowledge engineers can work with subject-matter experts as well as software engineers to develop models of expertise. At all points in the process, experts can understand and modify the models, even when models are fully operational. We were easily able to embed Rhino and immediately extend our language with Rhino's high-quality JavaScript interpreter.
|
||||
|
||||
<p><a href="http://httpunit.sourceforge.net/">HttpUnit</a>
|
||||
<br>"Automated testing is a great way to ensure that code being maintained works. The Extreme Programming (XP) methodology relies heavily on it, and practitioners have available to them a range of testing frameworks, most of which work by making direct calls to the code being tested. But what if you want to test a web application? Or what if you simply want to use a web-site as part of a distributed application?
|
||||
<p>
|
||||
In either case, you need to be able to bypass the browser and access your site from a program. HttpUnit makes this easy. Written in Java, HttpUnit emulates the relevant portions of browser behavior, including form submission, JavaScript, basic http authentication, cookies and automatic page redirection, and allows Java test code to examine returned pages either as text, an XML DOM, or containers of forms, tables, and links. When combined with a framework such as JUnit, it is fairly easy to write tests that very quickly verify the functioning of a web site."
|
||||
|
||||
<p><a href="http://htmlunit.sourceforge.net/">HtmlUnit</a>
|
||||
<br> HtmlUnit is a java unit testing framework for testing web based applications. </br>
|
||||
|
||||
<p><a href="http://www.icesoft.com/">ICEsoft Technologies</a>
|
||||
<br>ICEsoft Technologies adds JavaScript support to their <a href="http://www.icesoft.com/ps_browser_overview.html">ICEbrowser</a> using Rhino.
|
||||
<br>ICEsoft Technologies adds JavaScript support to their browser products using Rhino.
|
||||
|
||||
<p><a href="http://sourceforge.net/projects/jscorba">JS/CORBA Adapter</a>
|
||||
<br>The JS/CORBA Adapter provides a mechanism for arbitrary Javascript objects to interact with each other transparently in a distributed Javascript system using CORBA.
|
||||
|
||||
<p><a href="http://www.lombardisoftware.com">Lombardi Software</a>
|
||||
<br>Lombardi Software's TeamWorks BPM platform uses Rhino for all
|
||||
embedded scripting.
|
||||
|
||||
<p><a href="http://www.magoosoft.com">Magoo Software</a>
|
||||
<br>"We've just released version 1.5 of MagooClient, an XML messaging client, with Rhino inside. The availability of Rhino 1.6R1 with E4X marks a significant breakthrough in the way that people work with XML content. Instead of merely editing, users can add their own custom logic to perform calculations, implement validation rules that test relationships between elements and crucially, add callouts to external Web Services to populate XML documents. There have been several attempts at this type of rich XML client in the past but none offer the familiarity, simplicity and adherence to standards offered by Rhino/JavaScript/E4X." -- John McGuire, CTO Magoo Software.
|
||||
|
||||
<p><a href="http://homepage.mac.com/pcbeard/JShell/">JShell</a>
|
||||
<br>Rhino is used as the scripting language for the open source command
|
||||
shell JShell written by Patrick Beard.
|
||||
<p><a href="http://www.softcom.com">Softcom</a>
|
||||
<br>The tight integration of Netscape's Java-based JavaScript 1.5 with
|
||||
Softcom's Java-based RealPlayer plugin, RJ, enables Softcom to quickly
|
||||
produce dynamic interactive video applications for our media/entertainment,
|
||||
retail and professional education clients, helping us to synchronize the
|
||||
full interactivity of the Web and e-commerce with streaming video, said
|
||||
Chris O'Brien, president and COO of Softcom. For the enhanced Oscarcast
|
||||
recently produced for E! Online during the Academy Awards, Softcom used
|
||||
RJ to embed Netscape's JavaScript 1.5 in the RealPlayer, successfully integrating
|
||||
interactive chat and Java games, along with streaming video, within the
|
||||
RealPlayer.
|
||||
<p><a href="http://www.tdiinc.com/">Technology Deployment International</a>
|
||||
<br>"Technology Deployment International selected the Java-based Netscape
|
||||
JavaScript engine to incorporate into the workflow module of our eBusiness
|
||||
Management System (eBMS) allowing our customers to integrate business logic
|
||||
into any workstep of their application," said Dr. Kelvin Liu, VP eBMS Development,
|
||||
Technology Deployment International. "It has been easy to embed, the support
|
||||
we received from the engineering team has been outstanding, and the performance
|
||||
of the JavaScript code is almost identical to the equivalent Java."
|
||||
|
||||
<p><a href="http://www.runitsoft.com/">RUnit Software</a>
|
||||
<br>RUnit Software uses Rhino as part of
|
||||
solutions for business-process automation, for example
|
||||
when the automation involves communicating with a
|
||||
web-interface.
|
||||
|
||||
<p><a href="http://www.seppia.org/">Seppia</a>
|
||||
<br>"Seppia is a simple technology to build and deploy any Java application.
|
||||
It gains from the synergy of Java and JavaScript and a minimum set of clear
|
||||
rules to organize their interaction. Seppia allows developers to create
|
||||
stand-alone applications from constituent parts.
|
||||
Each part is a module: a unit of function integrating seamlessly JavaScript
|
||||
files, jar files and other resources.
|
||||
Seppia uses Mozilla Rhino to empower its JavaScript engine.
|
||||
Seppia will challenge the way you think of Java-based component computing."
|
||||
|
||||
|
||||
<p><a href="http://www.xmoon.org">XMoon</a>
|
||||
<br>XMoon is a dynamic OO (Object Oriented) opensource extension released under LGPL License for Jakarta Struts, powerful and easy to use.
|
||||
|
||||
XMoon lets you develop business logic classes following a fully Java compatible scripting language allowing execution of Java code at runtime without any access to a compiler.
|
||||
|
||||
<p><a href="http://www.xypoint.com/">XYPOINT</a>
|
||||
<br>XYPOINT uses Rhino for automating test cases of their Java classes
|
||||
used in their service <a href="http://www.webwirelessnow.com/">WebWirelessNow</a>.
|
||||
|
||||
@@ -1,36 +1,39 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
import org.mozilla.javascript.*;
|
||||
|
||||
@@ -50,55 +53,47 @@ public class Control {
|
||||
* Then set up the execution environment and begin to
|
||||
* execute scripts.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Context cx = Context.enter();
|
||||
|
||||
// Set version to JavaScript1.2 so that we get object-literal style
|
||||
// printing instead of "[object Object]"
|
||||
cx.setLanguageVersion(Context.VERSION_1_2);
|
||||
|
||||
// Initialize the standard objects (Object, Function, etc.)
|
||||
// This must be done before scripts can be executed.
|
||||
Scriptable scope = cx.initStandardObjects();
|
||||
|
||||
// Now we can evaluate a script. Let's create a new object
|
||||
// using the object literal notation.
|
||||
Object result = null;
|
||||
try {
|
||||
result = cx.evaluateString(scope, "obj = {a:1, b:['x','y']}",
|
||||
// Set version to JavaScript1.2 so that we get object-literal style
|
||||
// printing instead of "[object Object]"
|
||||
cx.setLanguageVersion(Context.VERSION_1_2);
|
||||
|
||||
// Initialize the standard objects (Object, Function, etc.)
|
||||
// This must be done before scripts can be executed.
|
||||
Scriptable scope = cx.initStandardObjects();
|
||||
|
||||
// Now we can evaluate a script. Let's create a new object
|
||||
// using the object literal notation.
|
||||
Object result = cx.evaluateString(scope, "obj = {a:1, b:['x','y']}",
|
||||
"MySource", 1, null);
|
||||
}
|
||||
catch (JavaScriptException jse) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
Scriptable obj = (Scriptable) scope.get("obj", scope);
|
||||
Scriptable obj = (Scriptable) scope.get("obj", scope);
|
||||
|
||||
// Should print "obj == result" (Since the result of an assignment
|
||||
// expression is the value that was assigned)
|
||||
System.out.println("obj " + (obj == result ? "==" : "!=") +
|
||||
" result");
|
||||
// Should print "obj == result" (Since the result of an assignment
|
||||
// expression is the value that was assigned)
|
||||
System.out.println("obj " + (obj == result ? "==" : "!=") +
|
||||
" result");
|
||||
|
||||
// Should print "obj.a == 1"
|
||||
System.out.println("obj.a == " + obj.get("a", obj));
|
||||
// Should print "obj.a == 1"
|
||||
System.out.println("obj.a == " + obj.get("a", obj));
|
||||
|
||||
Scriptable b = (Scriptable) obj.get("b", obj);
|
||||
Scriptable b = (Scriptable) obj.get("b", obj);
|
||||
|
||||
// Should print "obj.b[0] == x"
|
||||
System.out.println("obj.b[0] == " + b.get(0, b));
|
||||
// Should print "obj.b[0] == x"
|
||||
System.out.println("obj.b[0] == " + b.get(0, b));
|
||||
|
||||
// Should print "obj.b[1] == y"
|
||||
System.out.println("obj.b[1] == " + b.get(1, b));
|
||||
// Should print "obj.b[1] == y"
|
||||
System.out.println("obj.b[1] == " + b.get(1, b));
|
||||
|
||||
try {
|
||||
// Should print {a:1, b:["x", "y"]}
|
||||
Function fn = (Function) ScriptableObject.getProperty(obj, "toString");
|
||||
System.out.println(fn.call(cx, scope, obj, new Object[0]));
|
||||
} catch (JavaScriptException e) {
|
||||
// ignore
|
||||
} finally {
|
||||
Context.exit();
|
||||
}
|
||||
|
||||
cx.exit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,37 +1,40 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Norris Boyd
|
||||
* Norris Boyd
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
import org.mozilla.javascript.*;
|
||||
|
||||
|
||||
@@ -1,37 +1,40 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Norris Boyd
|
||||
* Norris Boyd
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
import org.mozilla.javascript.*;
|
||||
|
||||
|
||||
@@ -1,37 +1,40 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Norris Boyd
|
||||
* Norris Boyd
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
import org.mozilla.javascript.*;
|
||||
|
||||
@@ -40,65 +43,94 @@ import org.mozilla.javascript.*;
|
||||
*/
|
||||
public class DynamicScopes {
|
||||
|
||||
static boolean useDynamicScope;
|
||||
|
||||
static class MyFactory extends ContextFactory
|
||||
{
|
||||
protected boolean hasFeature(Context cx, int featureIndex)
|
||||
{
|
||||
if (featureIndex == Context.FEATURE_DYNAMIC_SCOPE) {
|
||||
return useDynamicScope;
|
||||
}
|
||||
return super.hasFeature(cx, featureIndex);
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
ContextFactory.initGlobal(new MyFactory());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Main entry point.
|
||||
*
|
||||
* Set up the shared scope and then spawn new threads that execute
|
||||
* relative to that shared scope. Try compiling functions with and
|
||||
* relative to that shared scope. Try to run functions with and
|
||||
* without dynamic scope to see the effect.
|
||||
*
|
||||
* The expected output is
|
||||
* <pre>
|
||||
* sharedScope
|
||||
* nested:sharedScope
|
||||
* sharedScope
|
||||
* nested:sharedScope
|
||||
* sharedScope
|
||||
* nested:sharedScope
|
||||
* thread0
|
||||
* nested:thread0
|
||||
* thread1
|
||||
* nested:thread1
|
||||
* thread2
|
||||
* nested:thread2
|
||||
* </pre>
|
||||
* The final three lines may be permuted in any order depending on
|
||||
* thread scheduling.
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
throws JavaScriptException
|
||||
{
|
||||
Context cx = Context.enter();
|
||||
try {
|
||||
cx.setCompileFunctionsWithDynamicScope(false);
|
||||
runScripts(cx);
|
||||
cx.setCompileFunctionsWithDynamicScope(true);
|
||||
runScripts(cx);
|
||||
// Precompile source only once
|
||||
String source = ""
|
||||
+"var x = 'sharedScope';\n"
|
||||
+"function f() { return x; }\n"
|
||||
// Dynamic scope works with nested function too
|
||||
+"function initClosure(prefix) {\n"
|
||||
+" return function test() { return prefix+x; }\n"
|
||||
+"}\n"
|
||||
+"var closure = initClosure('nested:');\n"
|
||||
+"";
|
||||
Script script = cx.compileString(source, "sharedScript", 1, null);
|
||||
|
||||
useDynamicScope = false;
|
||||
runScripts(cx, script);
|
||||
useDynamicScope = true;
|
||||
runScripts(cx, script);
|
||||
} finally {
|
||||
cx.exit();
|
||||
}
|
||||
}
|
||||
|
||||
static void runScripts(Context cx)
|
||||
throws JavaScriptException
|
||||
static void runScripts(Context cx, Script script)
|
||||
{
|
||||
// Initialize the standard objects (Object, Function, etc.)
|
||||
// This must be done before scripts can be executed. The call
|
||||
// returns a new scope that we will share.
|
||||
ScriptableObject scope = cx.initStandardObjects(null, true);
|
||||
ScriptableObject sharedScope = cx.initStandardObjects(null, true);
|
||||
|
||||
// Now we can evaluate a script and functions will be compiled to
|
||||
// use dynamic scope if the Context is so initialized.
|
||||
String source = "var x = 'sharedScope';" +
|
||||
"function f() { return x; }";
|
||||
cx.evaluateString(scope, source, "MySource", 1, null);
|
||||
// Now we can execute the precompiled script against the scope
|
||||
// to define x variable and f function in the shared scope.
|
||||
script.exec(cx, sharedScope);
|
||||
|
||||
// Now we spawn some threads that execute a script that calls the
|
||||
// function 'f'. The scope chain looks like this:
|
||||
// <pre>
|
||||
// ------------------
|
||||
// | shared scope |
|
||||
// ------------------
|
||||
// ------------------ ------------------
|
||||
// | per-thread scope | -prototype-> | shared scope |
|
||||
// ------------------ ------------------
|
||||
// ^
|
||||
// |
|
||||
// ------------------
|
||||
// | per-thread scope |
|
||||
// ------------------
|
||||
// ^
|
||||
// parentScope
|
||||
// |
|
||||
// ------------------
|
||||
// | f's activation |
|
||||
@@ -112,9 +144,13 @@ public class DynamicScopes {
|
||||
final int threadCount = 3;
|
||||
Thread[] t = new Thread[threadCount];
|
||||
for (int i=0; i < threadCount; i++) {
|
||||
String script = "function g() { var x = 'local'; return f(); }" +
|
||||
"java.lang.System.out.println(g());";
|
||||
t[i] = new Thread(new PerThread(scope, script,
|
||||
String source2 = ""
|
||||
+"function g() { var x = 'local'; return f(); }\n"
|
||||
+"java.lang.System.out.println(g());\n"
|
||||
+"function g2() { var x = 'local'; return closure(); }\n"
|
||||
+"java.lang.System.out.println(g2());\n"
|
||||
+"";
|
||||
t[i] = new Thread(new PerThread(sharedScope, source2,
|
||||
"thread" + i));
|
||||
}
|
||||
for (int i=0; i < threadCount; i++)
|
||||
@@ -131,9 +167,9 @@ public class DynamicScopes {
|
||||
|
||||
static class PerThread implements Runnable {
|
||||
|
||||
PerThread(Scriptable scope, String script, String x) {
|
||||
this.scope = scope;
|
||||
this.script = script;
|
||||
PerThread(Scriptable sharedScope, String source, String x) {
|
||||
this.sharedScope = sharedScope;
|
||||
this.source = source;
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
@@ -142,8 +178,8 @@ public class DynamicScopes {
|
||||
Context cx = Context.enter();
|
||||
try {
|
||||
// We can share the scope.
|
||||
Scriptable threadScope = cx.newObject(scope);
|
||||
threadScope.setPrototype(scope);
|
||||
Scriptable threadScope = cx.newObject(sharedScope);
|
||||
threadScope.setPrototype(sharedScope);
|
||||
|
||||
// We want "threadScope" to be a new top-level
|
||||
// scope, so set its parent scope to null. This
|
||||
@@ -154,17 +190,13 @@ public class DynamicScopes {
|
||||
// Create a JavaScript property of the thread scope named
|
||||
// 'x' and save a value for it.
|
||||
threadScope.put("x", threadScope, x);
|
||||
cx.evaluateString(threadScope, script, "threadScript", 1, null);
|
||||
}
|
||||
catch (JavaScriptException jse) {
|
||||
// ignore
|
||||
}
|
||||
finally {
|
||||
cx.evaluateString(threadScope, source, "threadScript", 1, null);
|
||||
} finally {
|
||||
Context.exit();
|
||||
}
|
||||
}
|
||||
private Scriptable scope;
|
||||
private String script;
|
||||
private Scriptable sharedScope;
|
||||
private String source;
|
||||
private String x;
|
||||
}
|
||||
|
||||
|
||||
223
mozilla/js/rhino/examples/E4X/e4x_example.js
Normal file
223
mozilla/js/rhino/examples/E4X/e4x_example.js
Normal file
@@ -0,0 +1,223 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John Schneider
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
print("----------------------------------------");
|
||||
|
||||
// Use the XML constructor to parse an string into an XML object
|
||||
var John = "<employee><name>John</name><age>25</age></employee>";
|
||||
var Sue ="<employee><name>Sue</name><age>32</age></employee>";
|
||||
var tagName = "employees";
|
||||
var employees = new XML("<" + tagName +">" + John + Sue + "</" + tagName +">");
|
||||
print("The employees XML object constructed from a string is:\n" + employees);
|
||||
|
||||
print("----------------------------------------");
|
||||
|
||||
// Use an XML literal to create an XML object
|
||||
var order = <order>
|
||||
<customer>
|
||||
<firstname>John</firstname>
|
||||
<lastname>Doe</lastname>
|
||||
</customer>
|
||||
<item>
|
||||
<description>Big Screen Television</description>
|
||||
<price>1299.99</price>
|
||||
<quantity>1</quantity>
|
||||
</item>
|
||||
</order>
|
||||
|
||||
// Construct the full customer name
|
||||
var name = order.customer.firstname + " " + order.customer.lastname;
|
||||
|
||||
// Calculate the total price
|
||||
var total = order.item.price * order.item.quantity;
|
||||
|
||||
print("The order XML object constructed using a literal is:\n" + order);
|
||||
print("The total price of " + name + "'s order is " + total);
|
||||
|
||||
print("----------------------------------------");
|
||||
|
||||
// construct a new XML object using expando and super-expando properties
|
||||
var order = <order/>;
|
||||
order.customer.name = "Fred Jones";
|
||||
order.customer.address.street = "123 Long Lang";
|
||||
order.customer.address.city = "Underwood";
|
||||
order.customer.address.state = "CA";
|
||||
order.item[0] = "";
|
||||
order.item[0].description = "Small Rodents";
|
||||
order.item[0].quantity = 10;
|
||||
order.item[0].price = 6.95;
|
||||
|
||||
print("The order custructed using expandos and super-expandos is:\n" + order);
|
||||
|
||||
// append a new item to the order
|
||||
order.item += <item><description>Catapult</description><price>139.95</price></item>;
|
||||
|
||||
print("----------------------------------------");
|
||||
|
||||
print("The order after appending a new item is:\n" + order);
|
||||
|
||||
print("----------------------------------------");
|
||||
|
||||
// dynamically construct an XML element using embedded expressions
|
||||
var tagname = "name";
|
||||
var attributename = "id";
|
||||
var attributevalue = 5;
|
||||
var content = "Fred";
|
||||
|
||||
var x = <{tagname} {attributename}={attributevalue}>{content}</{tagname}>;
|
||||
|
||||
print("The dynamically computed element value is:\n" + x.toXMLString());
|
||||
|
||||
print("----------------------------------------");
|
||||
|
||||
// Create a SOAP message
|
||||
var message = <soap:Envelope
|
||||
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
|
||||
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
|
||||
<soap:Body>
|
||||
<m:GetLastTradePrice xmlns:m="http://mycompany.com/stocks">
|
||||
<symbol>DIS</symbol>
|
||||
</m:GetLastTradePrice>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
||||
|
||||
// declare the SOAP and stocks namespaces
|
||||
var soap = new Namespace("http://schemas.xmlsoap.org/soap/envelope/");
|
||||
var stock = new Namespace ("http://mycompany.com/stocks");
|
||||
|
||||
// extract the soap encoding style and body from the soap message
|
||||
var encodingStyle = message.@soap::encodingStyle;
|
||||
|
||||
print("The encoding style of the soap message is specified by:\n" + encodingStyle);
|
||||
|
||||
// change the stock symbol
|
||||
message.soap::Body.stock::GetLastTradePrice.symbol = "MYCO";
|
||||
|
||||
var body = message.soap::Body;
|
||||
|
||||
print("The body of the soap message is:\n" + body);
|
||||
|
||||
print("----------------------------------------");
|
||||
|
||||
// create an manipulate an XML object using the default xml namespace
|
||||
|
||||
default xml namespace = "http://default.namespace.com";
|
||||
var x = <x/>;
|
||||
x.a = "one";
|
||||
x.b = "two";
|
||||
x.c = <c xmlns="http://some.other.namespace.com">three</c>;
|
||||
|
||||
print("XML object constructed using the default xml namespace:\n" + x);
|
||||
|
||||
default xml namespace="";
|
||||
|
||||
print("----------------------------------------");
|
||||
|
||||
var order = <order id = "123456" timestamp="Mon Mar 10 2003 16:03:25 GMT-0800 (PST)">
|
||||
<customer>
|
||||
<firstname>John</firstname>
|
||||
<lastname>Doe</lastname>
|
||||
</customer>
|
||||
<item id="3456">
|
||||
<description>Big Screen Television</description>
|
||||
<price>1299.99</price>
|
||||
<quantity>1</quantity>
|
||||
</item>
|
||||
<item id = "56789">
|
||||
<description>DVD Player</description>
|
||||
<price>399.99</price>
|
||||
<quantity>1</quantity>
|
||||
</item>
|
||||
</order>;
|
||||
|
||||
|
||||
// get the customer element from the orderprint("The customer is:\n" + order.customer);
|
||||
|
||||
// get the id attribute from the order
|
||||
print("The order id is:" + order.@id);
|
||||
|
||||
// get all the child elements from the order element
|
||||
print("The children of the order are:\n" + order.*);
|
||||
|
||||
// get the list of all item descriptions
|
||||
print("The order descriptions are:\n" + order.item.description);
|
||||
|
||||
|
||||
// get second item by numeric index
|
||||
print("The second item is:\n" + order.item[1]);
|
||||
|
||||
// get the list of all child elements in all item elements
|
||||
print("The children of the items are:\n" + order.item.*);
|
||||
|
||||
// get the second child element from the order by index
|
||||
print("The second child of the order is:\n" + order.*[1]);
|
||||
|
||||
// calculate the total price of the order
|
||||
var totalprice = 0;
|
||||
for each (i in order.item) {
|
||||
totalprice += i.price * i.quantity;
|
||||
}
|
||||
print("The total price of the order is: " + totalprice);
|
||||
|
||||
print("----------------------------------------");
|
||||
|
||||
var e = <employees>
|
||||
<employee id="1"><name>Joe</name><age>20</age></employee>
|
||||
<employee id="2"><name>Sue</name><age>30</age></employee>
|
||||
</employees>;
|
||||
|
||||
// get all the names in e
|
||||
print("All the employee names are:\n" + e..name);
|
||||
|
||||
// employees with name Joe
|
||||
print("The employee named Joe is:\n" + e.employee.(name == "Joe"));
|
||||
|
||||
// employees with id's 1 & 2
|
||||
print("Employees with ids 1 & 2:\n" + e.employee.(@id == 1 || @id == 2));
|
||||
|
||||
// name of employee with id 1
|
||||
print("Name of the the employee with ID=1: " + e.employee.(@id == 1).name);
|
||||
|
||||
print("----------------------------------------");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,37 +1,40 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Norris Boyd
|
||||
* Norris Boyd
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
import org.mozilla.javascript.*;
|
||||
import java.io.*;
|
||||
@@ -128,11 +131,9 @@ public class File extends ScriptableObject {
|
||||
*
|
||||
* @exception IOException if an error occurred while accessing the file
|
||||
* associated with this object
|
||||
* @exception JavaScriptException if a JavaScript exception occurred
|
||||
* while creating the result array
|
||||
*/
|
||||
public Object jsFunction_readLines()
|
||||
throws IOException, JavaScriptException
|
||||
throws IOException
|
||||
{
|
||||
Vector v = new Vector();
|
||||
String s;
|
||||
@@ -234,7 +235,7 @@ public class File extends ScriptableObject {
|
||||
*
|
||||
* Close the file when this object is collected.
|
||||
*/
|
||||
public void finalize() {
|
||||
protected void finalize() {
|
||||
try {
|
||||
jsFunction_close();
|
||||
}
|
||||
@@ -252,7 +253,7 @@ public class File extends ScriptableObject {
|
||||
// in a Scriptable object so that it can be manipulated by
|
||||
// JavaScript.
|
||||
Scriptable parent = ScriptableObject.getTopLevelScope(this);
|
||||
return Context.toObject(reader, parent);
|
||||
return Context.javaToJS(reader, parent);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -265,7 +266,7 @@ public class File extends ScriptableObject {
|
||||
if (writer == null)
|
||||
return null;
|
||||
Scriptable parent = ScriptableObject.getTopLevelScope(this);
|
||||
return Context.toObject(writer, parent);
|
||||
return Context.javaToJS(writer, parent);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,36 +1,39 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
import org.mozilla.javascript.*;
|
||||
|
||||
|
||||
@@ -1,36 +1,39 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
import org.mozilla.javascript.*;
|
||||
import java.util.Vector;
|
||||
|
||||
@@ -1,3 +1,37 @@
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<html>
|
||||
<body>
|
||||
This is the NervousText applet in javascript:
|
||||
|
||||
@@ -1,3 +1,37 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// The Java "NervousText" example ported to JavaScript.
|
||||
// Compile using java org.mozilla.javascript.tools.jsc.Main -extends java.applet.Applet -implements java.lang.Runnable NervousText.js
|
||||
/*
|
||||
|
||||
@@ -1,37 +1,40 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Norris Boyd
|
||||
* Norris Boyd
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
import org.mozilla.javascript.*;
|
||||
|
||||
|
||||
@@ -1,36 +1,39 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
import org.mozilla.javascript.*;
|
||||
|
||||
@@ -44,7 +47,6 @@ import org.mozilla.javascript.*;
|
||||
*/
|
||||
public class RunScript {
|
||||
public static void main(String args[])
|
||||
throws JavaScriptException
|
||||
{
|
||||
// Creates and enters a Context. The Context stores information
|
||||
// about the execution environment of a script.
|
||||
|
||||
@@ -1,36 +1,39 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
import org.mozilla.javascript.*;
|
||||
|
||||
@@ -41,7 +44,6 @@ import org.mozilla.javascript.*;
|
||||
*/
|
||||
public class RunScript2 {
|
||||
public static void main(String args[])
|
||||
throws JavaScriptException
|
||||
{
|
||||
Context cx = Context.enter();
|
||||
try {
|
||||
@@ -49,8 +51,8 @@ public class RunScript2 {
|
||||
|
||||
// Add a global variable "out" that is a JavaScript reflection
|
||||
// of System.out
|
||||
Scriptable jsArgs = Context.toObject(System.out, scope);
|
||||
scope.put("out", scope, jsArgs);
|
||||
Object jsOut = Context.javaToJS(System.out, scope);
|
||||
ScriptableObject.putProperty(scope, "out", jsOut);
|
||||
|
||||
String s = "";
|
||||
for (int i=0; i < args.length; i++) {
|
||||
|
||||
@@ -1,36 +1,39 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
import org.mozilla.javascript.*;
|
||||
|
||||
@@ -44,7 +47,6 @@ import org.mozilla.javascript.*;
|
||||
*/
|
||||
public class RunScript3 {
|
||||
public static void main(String args[])
|
||||
throws JavaScriptException
|
||||
{
|
||||
Context cx = Context.enter();
|
||||
try {
|
||||
|
||||
@@ -1,36 +1,39 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
import org.mozilla.javascript.*;
|
||||
|
||||
|
||||
@@ -1,36 +1,39 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
import org.mozilla.javascript.*;
|
||||
import java.io.*;
|
||||
@@ -70,12 +73,8 @@ public class Shell extends ScriptableObject
|
||||
// Define some global functions particular to the shell. Note
|
||||
// that these functions are not part of ECMA.
|
||||
String[] names = { "print", "quit", "version", "load", "help" };
|
||||
try {
|
||||
shell.defineFunctionProperties(names, Shell.class,
|
||||
ScriptableObject.DONTENUM);
|
||||
} catch (PropertyException e) {
|
||||
throw new Error(e.getMessage());
|
||||
}
|
||||
shell.defineFunctionProperties(names, Shell.class,
|
||||
ScriptableObject.DONTENUM);
|
||||
|
||||
args = processOptions(cx, args);
|
||||
|
||||
@@ -333,7 +332,6 @@ public class Shell extends ScriptableObject
|
||||
}
|
||||
}
|
||||
}
|
||||
System.gc();
|
||||
}
|
||||
|
||||
private static void p(String s) {
|
||||
|
||||
@@ -1,3 +1,37 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* SwingApplication.js - a translation into JavaScript of
|
||||
* SwingApplication.java, a java.sun.com Swing example.
|
||||
@@ -5,57 +39,73 @@
|
||||
* @author Roger E Critchlow, Jr.
|
||||
*/
|
||||
|
||||
importPackage(Packages.javax.swing);
|
||||
importPackage(Packages.java.awt);
|
||||
importPackage(Packages.java.awt.event);
|
||||
var swingNames = JavaImporter();
|
||||
|
||||
function createComponents() {
|
||||
var labelPrefix = "Number of button clicks: ";
|
||||
var numClicks = 0;
|
||||
var label = new JLabel(labelPrefix + numClicks);
|
||||
var button = new JButton("I'm a Swing button!");
|
||||
button.mnemonic = KeyEvent.VK_I;
|
||||
// Since Rhino 1.5R5 JS functions can be passed to Java method if
|
||||
// corresponding argument type is Java interface with single method.
|
||||
button.addActionListener(function() {
|
||||
numClicks += 1;
|
||||
label.setText(labelPrefix + numClicks);
|
||||
});
|
||||
label.setLabelFor(button);
|
||||
swingNames.importPackage(Packages.javax.swing);
|
||||
swingNames.importPackage(Packages.java.awt);
|
||||
swingNames.importPackage(Packages.java.awt.event);
|
||||
|
||||
/*
|
||||
* An easy way to put space between a top-level container
|
||||
* and its contents is to put the contents in a JPanel
|
||||
* that has an "empty" border.
|
||||
*/
|
||||
var pane = new JPanel();
|
||||
pane.border = BorderFactory.createEmptyBorder(30, //top
|
||||
30, //left
|
||||
10, //bottom
|
||||
30); //right
|
||||
pane.setLayout(new GridLayout(0, 1));
|
||||
pane.add(button);
|
||||
pane.add(label);
|
||||
function createComponents()
|
||||
{
|
||||
with (swingNames) {
|
||||
var labelPrefix = "Number of button clicks: ";
|
||||
var numClicks = 0;
|
||||
var label = new JLabel(labelPrefix + numClicks);
|
||||
var button = new JButton("I'm a Swing button!");
|
||||
button.mnemonic = KeyEvent.VK_I;
|
||||
// Since Rhino 1.5R5 JS functions can be passed to Java method if
|
||||
// corresponding argument type is Java interface with single method
|
||||
// or all its methods have the same number of arguments and the
|
||||
// corresponding arguments has the same type. See also comments for
|
||||
// frame.addWindowListener bellow
|
||||
button.addActionListener(function() {
|
||||
numClicks += 1;
|
||||
label.setText(labelPrefix + numClicks);
|
||||
});
|
||||
label.setLabelFor(button);
|
||||
|
||||
return pane;
|
||||
/*
|
||||
* An easy way to put space between a top-level container
|
||||
* and its contents is to put the contents in a JPanel
|
||||
* that has an "empty" border.
|
||||
*/
|
||||
var pane = new JPanel();
|
||||
pane.border = BorderFactory.createEmptyBorder(30, //top
|
||||
30, //left
|
||||
10, //bottom
|
||||
30); //right
|
||||
pane.setLayout(new GridLayout(0, 1));
|
||||
pane.add(button);
|
||||
pane.add(label);
|
||||
|
||||
return pane;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
|
||||
} catch (e) { }
|
||||
with (swingNames) {
|
||||
try {
|
||||
UIManager.
|
||||
setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
|
||||
} catch (e) { }
|
||||
|
||||
//Create the top-level container and add contents to it.
|
||||
var frame = new JFrame("SwingApplication");
|
||||
frame.getContentPane().add(createComponents(), BorderLayout.CENTER);
|
||||
//Create the top-level container and add contents to it.
|
||||
var frame = new swingNames.JFrame("SwingApplication");
|
||||
frame.getContentPane().add(createComponents(), BorderLayout.CENTER);
|
||||
|
||||
//Finish setting up the frame, and show it.
|
||||
frame.addWindowListener(new WindowAdapter({
|
||||
windowClosing : function() {
|
||||
java.lang.System.exit(0);
|
||||
}
|
||||
}) );
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
// Pass JS function as implementation of WindowListener. It is allowed since
|
||||
// all methods in WindowListener have the same signature. To distinguish
|
||||
// between methods Rhino passes to JS function the name of corresponding
|
||||
// method as the last argument
|
||||
frame.addWindowListener(function(event, methodName) {
|
||||
if (methodName == "windowClosing") {
|
||||
java.lang.System.exit(0);
|
||||
}
|
||||
});
|
||||
|
||||
//Finish setting up the frame, and show it.
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,37 +1,40 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Norris Boyd
|
||||
* Norris Boyd
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/**
|
||||
* checkParam.js
|
||||
|
||||
@@ -1,69 +1,68 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/* -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Patrick Beard
|
||||
* Patrick Beard
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
enum.js
|
||||
Implementing the interface java.util.Enumeration passing the object
|
||||
with JavaScript implementation directly to the constructor.
|
||||
This is a shorthand for JavaAdapter constructor:
|
||||
|
||||
Implementing the interface java.util.Enumeration using the new syntax.
|
||||
Note that this syntax is experimental only, and hasn't been approved
|
||||
by ECMA.
|
||||
The same functionality can be had without the new syntax using the
|
||||
uglier syntax:
|
||||
|
||||
var elements = new JavaAdapter(java.util.Enumeration, {
|
||||
index: 0, elements: array,
|
||||
hasMoreElements: function ...
|
||||
nextElement: function ...
|
||||
elements = new JavaAdapter(java.util.Enumeration, {
|
||||
index: 0,
|
||||
elements: array,
|
||||
hasMoreElements: function ...
|
||||
nextElement: function ...
|
||||
});
|
||||
|
||||
by Patrick C. Beard.
|
||||
*/
|
||||
|
||||
// an array to enumerate.
|
||||
var array = [0, 1, 2];
|
||||
|
||||
// create an array enumeration.
|
||||
var elements = new java.util.Enumeration() {
|
||||
index: 0, elements: array,
|
||||
hasMoreElements: function() {
|
||||
return (this.index < this.elements.length);
|
||||
},
|
||||
nextElement: function() {
|
||||
return this.elements[this.index++];
|
||||
var elements = new java.util.Enumeration({
|
||||
index: 0,
|
||||
elements: array,
|
||||
hasMoreElements: function() {
|
||||
return (this.index < this.elements.length);
|
||||
},
|
||||
nextElement: function() {
|
||||
return this.elements[this.index++];
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
// now print out the array by enumerating through the Enumeration
|
||||
while (elements.hasMoreElements())
|
||||
|
||||
@@ -1,38 +1,41 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Norris Boyd
|
||||
* Roland Pennings
|
||||
* Norris Boyd
|
||||
* Roland Pennings
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/**
|
||||
* Process a JavaScript source file and process special comments
|
||||
@@ -127,7 +130,7 @@ function processFile(f, fname, inputdir, out) {
|
||||
functionDocArray[functionDocArray.length] = {name:m[1], text:htmlText};
|
||||
|
||||
// Store the function also in the indexFunctionArray
|
||||
// so we can have a seperate file with the function table of contents
|
||||
// so we can have a separate file with the function table of contents
|
||||
if (indexFunctionArray[m[1]]) {
|
||||
// print("ERROR: function: " + m[1] + " is defined more than once!");
|
||||
// Allow multiple files for a function
|
||||
@@ -154,7 +157,7 @@ function processFile(f, fname, inputdir, out) {
|
||||
functionDocArray[functionDocArray.length] = {name:m[1]+".prototype."+m[2], text:htmlText};
|
||||
|
||||
// Store the function also in the indexFunctionArray
|
||||
// so we can have a seperate file with the function table of contents
|
||||
// so we can have a separate file with the function table of contents
|
||||
if (indexFunctionArray[m[1]]) {
|
||||
// print("ERROR: function: " + m[1] + " is defined more than once!");
|
||||
// Allow multiple files for a function
|
||||
|
||||
@@ -1,37 +1,40 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Norris Boyd
|
||||
* Norris Boyd
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/**
|
||||
* liveConnect.js: a simple demonstration of JavaScript-to-Java connectivity
|
||||
|
||||
@@ -1,37 +1,40 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Norris Boyd
|
||||
* Norris Boyd
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// unique.js: read the contents of a file and print out the unique lines
|
||||
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -1,39 +1,77 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Rhino code, released May 6, 1999.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
- case the provisions of the GPL are applicable instead of those above. If
|
||||
- you wish to allow use of your version of this file only under the terms of
|
||||
- the GPL and not to allow others to use your version of this file under the
|
||||
- MPL, indicate your decision by deleting the provisions above and replacing
|
||||
- them with the notice and other provisions required by the GPL. If you do
|
||||
- not delete the provisions above, a recipient may use your version of this
|
||||
- file under either the MPL or the GPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
|
||||
<!--
|
||||
Build file for Rhino using Ant (see http://jakarta.apache.org/ant/index.html)
|
||||
Requires Ant version 1.2
|
||||
-->
|
||||
<project name="src" default="compile" basedir=".">
|
||||
<project name="src" default="compile" basedir="..">
|
||||
|
||||
<property file="build.properties"/>
|
||||
|
||||
<target name="properties">
|
||||
<property name="nest" value=".."/>
|
||||
<property name="build.dir" value="./build"/>
|
||||
<property name="classes" value="${build.dir}/classes"/>
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="properties">
|
||||
<javac srcdir="."
|
||||
destdir="${nest}/${classes}"
|
||||
<target name="compile">
|
||||
<javac srcdir="src"
|
||||
destdir="${classes}"
|
||||
includes="org/**/*.java"
|
||||
deprecation="on"
|
||||
debug="${debug}">
|
||||
debug="${debug}"
|
||||
target="${target-jvm}"
|
||||
source="${source-level}"
|
||||
>
|
||||
</javac>
|
||||
<copy todir="${nest}/${classes}">
|
||||
<fileset dir="." includes="org/**/*.properties" />
|
||||
<copy todir="${classes}">
|
||||
<fileset dir="src" includes="org/**/*.properties" />
|
||||
<filterset>
|
||||
<filter token="IMPLEMENTATION.VERSION"
|
||||
value="${implementation.version}"/>
|
||||
</filterset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="copy-source" depends="properties">
|
||||
<copy todir="${nest}/${dist.src}">
|
||||
<fileset dir="."
|
||||
includes="org/**/*.java,org/**/*.properties,build.xml,manifest"/>
|
||||
<target name="copy-source">
|
||||
<mkdir dir="${dist.dir}/src"/>
|
||||
<copy todir="${dist.dir}/src">
|
||||
<fileset dir="src"
|
||||
includes="**/*.java,**/*.properties,**/*.xml,manifest"/>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="clean" depends="properties">
|
||||
<target name="clean">
|
||||
<delete includeEmptyDirs="true">
|
||||
<fileset dir="${nest}/${classes}"
|
||||
<fileset dir="${classes}"
|
||||
excludes="org/mozilla/javascript/tools/**"/>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: org.mozilla.javascript.tools.shell.Main
|
||||
Class-Path: xbean.jar
|
||||
|
||||
@@ -1,37 +1,40 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Roger Lawrence
|
||||
* Roger Lawrence
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
package org.mozilla.classfile;
|
||||
|
||||
@@ -47,7 +50,7 @@ public class ByteCode {
|
||||
/**
|
||||
* The byte opcodes defined by the Java Virtual Machine.
|
||||
*/
|
||||
public static final byte
|
||||
public static final int
|
||||
NOP = 0x00,
|
||||
ACONST_NULL = 0x01,
|
||||
ICONST_M1 = 0x02,
|
||||
@@ -176,83 +179,83 @@ public class ByteCode {
|
||||
LUSHR = 0x7D,
|
||||
IAND = 0x7E,
|
||||
LAND = 0x7F,
|
||||
IOR = (byte)0x80,
|
||||
LOR = (byte)0x81,
|
||||
IXOR = (byte)0x82,
|
||||
LXOR = (byte)0x83,
|
||||
IINC = (byte)0x84,
|
||||
I2L = (byte)0x85,
|
||||
I2F = (byte)0x86,
|
||||
I2D = (byte)0x87,
|
||||
L2I = (byte)0x88,
|
||||
L2F = (byte)0x89,
|
||||
L2D = (byte)0x8A,
|
||||
F2I = (byte)0x8B,
|
||||
F2L = (byte)0x8C,
|
||||
F2D = (byte)0x8D,
|
||||
D2I = (byte)0x8E,
|
||||
D2L = (byte)0x8F,
|
||||
D2F = (byte)0x90,
|
||||
I2B = (byte)0x91,
|
||||
I2C = (byte)0x92,
|
||||
I2S = (byte)0x93,
|
||||
LCMP = (byte)0x94,
|
||||
FCMPL = (byte)0x95,
|
||||
FCMPG = (byte)0x96,
|
||||
DCMPL = (byte)0x97,
|
||||
DCMPG = (byte)0x98,
|
||||
IFEQ = (byte)0x99,
|
||||
IFNE = (byte)0x9A,
|
||||
IFLT = (byte)0x9B,
|
||||
IFGE = (byte)0x9C,
|
||||
IFGT = (byte)0x9D,
|
||||
IFLE = (byte)0x9E,
|
||||
IF_ICMPEQ = (byte)0x9F,
|
||||
IF_ICMPNE = (byte)0xA0,
|
||||
IF_ICMPLT = (byte)0xA1,
|
||||
IF_ICMPGE = (byte)0xA2,
|
||||
IF_ICMPGT = (byte)0xA3,
|
||||
IF_ICMPLE = (byte)0xA4,
|
||||
IF_ACMPEQ = (byte)0xA5,
|
||||
IF_ACMPNE = (byte)0xA6,
|
||||
GOTO = (byte)0xA7,
|
||||
JSR = (byte)0xA8,
|
||||
RET = (byte)0xA9,
|
||||
TABLESWITCH = (byte)0xAA,
|
||||
LOOKUPSWITCH = (byte)0xAB,
|
||||
IRETURN = (byte)0xAC,
|
||||
LRETURN = (byte)0xAD,
|
||||
FRETURN = (byte)0xAE,
|
||||
DRETURN = (byte)0xAF,
|
||||
ARETURN = (byte)0xB0,
|
||||
RETURN = (byte)0xB1,
|
||||
GETSTATIC = (byte)0xB2,
|
||||
PUTSTATIC = (byte)0xB3,
|
||||
GETFIELD = (byte)0xB4,
|
||||
PUTFIELD = (byte)0xB5,
|
||||
INVOKEVIRTUAL = (byte)0xB6,
|
||||
INVOKESPECIAL = (byte)0xB7,
|
||||
INVOKESTATIC = (byte)0xB8,
|
||||
INVOKEINTERFACE = (byte)0xB9,
|
||||
NEW = (byte)0xBB,
|
||||
NEWARRAY = (byte)0xBC,
|
||||
ANEWARRAY = (byte)0xBD,
|
||||
ARRAYLENGTH = (byte)0xBE,
|
||||
ATHROW = (byte)0xBF,
|
||||
CHECKCAST = (byte)0xC0,
|
||||
INSTANCEOF = (byte)0xC1,
|
||||
MONITORENTER = (byte)0xC2,
|
||||
MONITOREXIT = (byte)0xC3,
|
||||
WIDE = (byte)0xC4,
|
||||
MULTIANEWARRAY = (byte)0xC5,
|
||||
IFNULL = (byte)0xC6,
|
||||
IFNONNULL = (byte)0xC7,
|
||||
GOTO_W = (byte)0xC8,
|
||||
JSR_W = (byte)0xC9,
|
||||
BREAKPOINT = (byte)0xCA,
|
||||
IOR = 0x80,
|
||||
LOR = 0x81,
|
||||
IXOR = 0x82,
|
||||
LXOR = 0x83,
|
||||
IINC = 0x84,
|
||||
I2L = 0x85,
|
||||
I2F = 0x86,
|
||||
I2D = 0x87,
|
||||
L2I = 0x88,
|
||||
L2F = 0x89,
|
||||
L2D = 0x8A,
|
||||
F2I = 0x8B,
|
||||
F2L = 0x8C,
|
||||
F2D = 0x8D,
|
||||
D2I = 0x8E,
|
||||
D2L = 0x8F,
|
||||
D2F = 0x90,
|
||||
I2B = 0x91,
|
||||
I2C = 0x92,
|
||||
I2S = 0x93,
|
||||
LCMP = 0x94,
|
||||
FCMPL = 0x95,
|
||||
FCMPG = 0x96,
|
||||
DCMPL = 0x97,
|
||||
DCMPG = 0x98,
|
||||
IFEQ = 0x99,
|
||||
IFNE = 0x9A,
|
||||
IFLT = 0x9B,
|
||||
IFGE = 0x9C,
|
||||
IFGT = 0x9D,
|
||||
IFLE = 0x9E,
|
||||
IF_ICMPEQ = 0x9F,
|
||||
IF_ICMPNE = 0xA0,
|
||||
IF_ICMPLT = 0xA1,
|
||||
IF_ICMPGE = 0xA2,
|
||||
IF_ICMPGT = 0xA3,
|
||||
IF_ICMPLE = 0xA4,
|
||||
IF_ACMPEQ = 0xA5,
|
||||
IF_ACMPNE = 0xA6,
|
||||
GOTO = 0xA7,
|
||||
JSR = 0xA8,
|
||||
RET = 0xA9,
|
||||
TABLESWITCH = 0xAA,
|
||||
LOOKUPSWITCH = 0xAB,
|
||||
IRETURN = 0xAC,
|
||||
LRETURN = 0xAD,
|
||||
FRETURN = 0xAE,
|
||||
DRETURN = 0xAF,
|
||||
ARETURN = 0xB0,
|
||||
RETURN = 0xB1,
|
||||
GETSTATIC = 0xB2,
|
||||
PUTSTATIC = 0xB3,
|
||||
GETFIELD = 0xB4,
|
||||
PUTFIELD = 0xB5,
|
||||
INVOKEVIRTUAL = 0xB6,
|
||||
INVOKESPECIAL = 0xB7,
|
||||
INVOKESTATIC = 0xB8,
|
||||
INVOKEINTERFACE = 0xB9,
|
||||
NEW = 0xBB,
|
||||
NEWARRAY = 0xBC,
|
||||
ANEWARRAY = 0xBD,
|
||||
ARRAYLENGTH = 0xBE,
|
||||
ATHROW = 0xBF,
|
||||
CHECKCAST = 0xC0,
|
||||
INSTANCEOF = 0xC1,
|
||||
MONITORENTER = 0xC2,
|
||||
MONITOREXIT = 0xC3,
|
||||
WIDE = 0xC4,
|
||||
MULTIANEWARRAY = 0xC5,
|
||||
IFNULL = 0xC6,
|
||||
IFNONNULL = 0xC7,
|
||||
GOTO_W = 0xC8,
|
||||
JSR_W = 0xC9,
|
||||
BREAKPOINT = 0xCA,
|
||||
|
||||
IMPDEP1 = (byte)0xFE,
|
||||
IMPDEP2 = (byte)0xFF;
|
||||
IMPDEP1 = 0xFE,
|
||||
IMPDEP2 = 0xFF;
|
||||
|
||||
/**
|
||||
* Types for the NEWARRAY opcode.
|
||||
|
||||
@@ -1,47 +1,48 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Roger Lawrence
|
||||
* Roger Lawrence
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
package org.mozilla.classfile;
|
||||
|
||||
import org.mozilla.javascript.LabelTable;
|
||||
import org.mozilla.javascript.ObjToIntMap;
|
||||
import org.mozilla.javascript.ObjArray;
|
||||
import org.mozilla.javascript.UintMap;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* ClassFileWriter
|
||||
@@ -235,6 +236,28 @@ public class ClassFileWriter {
|
||||
itsFields.add(field);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Information about java variable to use when generating the local
|
||||
* variable table.
|
||||
*
|
||||
* @param name variable name.
|
||||
* @param type variable type as bytecode descriptor string.
|
||||
* @param startPC the starting bytecode PC where this variable is live,
|
||||
* or -1 if it does not have a Java register.
|
||||
* @param register the Java register number of variable
|
||||
* or -1 if it does not have a Java register.
|
||||
*/
|
||||
public void addVariableDescriptor(String name, String type, int startPC, int register)
|
||||
{
|
||||
int nameIndex = itsConstantPool.addUtf8(name);
|
||||
int descriptorIndex = itsConstantPool.addUtf8(type);
|
||||
int [] chunk = { nameIndex, descriptorIndex, startPC, register };
|
||||
if (itsVarDescriptors == null) {
|
||||
itsVarDescriptors = new ObjArray();
|
||||
}
|
||||
itsVarDescriptors.add(chunk);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a method and begin adding code.
|
||||
*
|
||||
@@ -265,11 +288,11 @@ public class ClassFileWriter {
|
||||
* @param vars the array of the variables for the method,
|
||||
* or null if none
|
||||
*/
|
||||
public void stopMethod(short maxLocals, JavaVariable[] vars) {
|
||||
public void stopMethod(short maxLocals) {
|
||||
if (itsCurrentMethod == null)
|
||||
throw new IllegalStateException("No method to stop");
|
||||
|
||||
itsLabels.fixLabelGotos(itsCodeBuffer);
|
||||
fixLabelGotos();
|
||||
|
||||
itsMaxLocals = maxLocals;
|
||||
|
||||
@@ -282,11 +305,11 @@ public class ClassFileWriter {
|
||||
}
|
||||
|
||||
int variableTableLength = 0;
|
||||
if (vars != null) {
|
||||
if (itsVarDescriptors != null) {
|
||||
// 6 bytes for the attribute header
|
||||
// 2 bytes for the variable count
|
||||
// 10 bytes for each entry
|
||||
variableTableLength = 6 + 2 + (vars.length * 10);
|
||||
variableTableLength = 6 + 2 + (itsVarDescriptors.size() * 10);
|
||||
}
|
||||
|
||||
int attrLength = 2 + // attribute_name_index
|
||||
@@ -301,7 +324,7 @@ public class ClassFileWriter {
|
||||
lineNumberTableLength +
|
||||
variableTableLength;
|
||||
|
||||
byte codeAttribute[] = new byte[attrLength];
|
||||
byte[] codeAttribute = new byte[attrLength];
|
||||
int index = 0;
|
||||
int codeAttrIndex = itsConstantPool.addUtf8("Code");
|
||||
index = putInt16(codeAttrIndex, codeAttribute, index);
|
||||
@@ -318,10 +341,19 @@ public class ClassFileWriter {
|
||||
if (itsExceptionTableTop > 0) {
|
||||
index = putInt16(itsExceptionTableTop, codeAttribute, index);
|
||||
for (int i = 0; i < itsExceptionTableTop; i++) {
|
||||
short startPC = itsExceptionTable[i].getStartPC(itsLabels);
|
||||
short endPC = itsExceptionTable[i].getEndPC(itsLabels);
|
||||
short handlerPC = itsExceptionTable[i].getHandlerPC(itsLabels);
|
||||
short catchType = itsExceptionTable[i].getCatchType();
|
||||
ExceptionTableEntry ete = itsExceptionTable[i];
|
||||
short startPC = (short)getLabelPC(ete.itsStartLabel);
|
||||
short endPC = (short)getLabelPC(ete.itsEndLabel);
|
||||
short handlerPC = (short)getLabelPC(ete.itsHandlerLabel);
|
||||
short catchType = ete.itsCatchType;
|
||||
if (startPC == -1)
|
||||
throw new IllegalStateException("start label not defined");
|
||||
if (endPC == -1)
|
||||
throw new IllegalStateException("end label not defined");
|
||||
if (handlerPC == -1)
|
||||
throw new IllegalStateException(
|
||||
"handler label not defined");
|
||||
|
||||
index = putInt16(startPC, codeAttribute, index);
|
||||
index = putInt16(endPC, codeAttribute, index);
|
||||
index = putInt16(handlerPC, codeAttribute, index);
|
||||
@@ -336,7 +368,7 @@ public class ClassFileWriter {
|
||||
int attributeCount = 0;
|
||||
if (itsLineNumberTable != null)
|
||||
attributeCount++;
|
||||
if (vars != null)
|
||||
if (itsVarDescriptors != null)
|
||||
attributeCount++;
|
||||
index = putInt16(attributeCount, codeAttribute, index);
|
||||
|
||||
@@ -352,32 +384,27 @@ public class ClassFileWriter {
|
||||
}
|
||||
}
|
||||
|
||||
if (vars != null) {
|
||||
if (itsVarDescriptors != null) {
|
||||
int variableTableAttrIndex
|
||||
= itsConstantPool.addUtf8("LocalVariableTable");
|
||||
index = putInt16(variableTableAttrIndex, codeAttribute, index);
|
||||
int varCount = vars.length;
|
||||
int varCount = itsVarDescriptors.size();
|
||||
int tableAttrLength = 2 + (varCount * 10);
|
||||
index = putInt32(tableAttrLength, codeAttribute, index);
|
||||
index = putInt16(varCount, codeAttribute, index);
|
||||
for (int i = 0; i < varCount; i++) {
|
||||
JavaVariable lvar = vars[i];
|
||||
int[] chunk = (int[])itsVarDescriptors.get(i);
|
||||
int nameIndex = chunk[0];
|
||||
int descriptorIndex = chunk[1];
|
||||
int startPC = chunk[2];
|
||||
int register = chunk[3];
|
||||
int length = itsCodeBufferTop - startPC;
|
||||
|
||||
int startPc = lvar.getStartPC();
|
||||
index = putInt16(startPc, codeAttribute, index);
|
||||
|
||||
int length = itsCodeBufferTop - startPc;
|
||||
index = putInt16(startPC, codeAttribute, index);
|
||||
index = putInt16(length, codeAttribute, index);
|
||||
|
||||
int nameIndex = itsConstantPool.addUtf8(lvar.getName());
|
||||
index = putInt16(nameIndex, codeAttribute, index);
|
||||
|
||||
String descriptor = lvar.getTypeDescriptor();
|
||||
int descriptorIndex = itsConstantPool.addUtf8(descriptor);
|
||||
index = putInt16(descriptorIndex, codeAttribute, index);
|
||||
|
||||
int jreg = lvar.getJRegister();
|
||||
index = putInt16(jreg, codeAttribute, index);
|
||||
index = putInt16(register, codeAttribute, index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,7 +417,9 @@ public class ClassFileWriter {
|
||||
itsCurrentMethod = null;
|
||||
itsMaxStack = 0;
|
||||
itsStackTop = 0;
|
||||
itsLabels.clearLabels();
|
||||
itsLabelTableTop = 0;
|
||||
itsFixupTableTop = 0;
|
||||
itsVarDescriptors = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -398,7 +427,7 @@ public class ClassFileWriter {
|
||||
*
|
||||
* @param theOpCode the opcode of the bytecode
|
||||
*/
|
||||
public void add(byte theOpCode) {
|
||||
public void add(int theOpCode) {
|
||||
if (opcodeCount(theOpCode) != 0)
|
||||
throw new IllegalArgumentException("Unexpected operands");
|
||||
int newStack = itsStackTop + stackChange(theOpCode);
|
||||
@@ -420,7 +449,7 @@ public class ClassFileWriter {
|
||||
* @param theOpCode the opcode of the bytecode
|
||||
* @param theOperand the operand of the bytecode
|
||||
*/
|
||||
public void add(byte theOpCode, int theOperand) {
|
||||
public void add(int theOpCode, int theOperand) {
|
||||
if (DEBUGCODE) {
|
||||
System.out.println("Add "+bytecodeStr(theOpCode)
|
||||
+", "+Integer.toHexString(theOperand));
|
||||
@@ -460,9 +489,9 @@ public class ClassFileWriter {
|
||||
addToCodeInt16(theOperand);
|
||||
}
|
||||
else { // a label
|
||||
int theLabel = theOperand & 0x7FFFFFFF;
|
||||
int targetPC = itsLabels.getLabelPC(theLabel);
|
||||
int targetPC = getLabelPC(theOperand);
|
||||
if (DEBUGLABELS) {
|
||||
int theLabel = theOperand & 0x7FFFFFFF;
|
||||
System.out.println("Fixing branch to " +
|
||||
theLabel + " at " + targetPC +
|
||||
" from " + branchPC);
|
||||
@@ -472,7 +501,7 @@ public class ClassFileWriter {
|
||||
addToCodeInt16(offset);
|
||||
}
|
||||
else {
|
||||
itsLabels.addLabelFixup(theLabel, branchPC + 1);
|
||||
addLabelFixup(theOperand, branchPC + 1);
|
||||
addToCodeInt16(0);
|
||||
}
|
||||
}
|
||||
@@ -497,7 +526,7 @@ public class ClassFileWriter {
|
||||
if (!(0 <= theOperand && theOperand < 256))
|
||||
throw new IllegalArgumentException("out of range index");
|
||||
addToCodeBuffer(theOpCode);
|
||||
addToCodeBuffer((byte)theOperand);
|
||||
addToCodeBuffer(theOperand);
|
||||
break;
|
||||
|
||||
case ByteCode.GETFIELD :
|
||||
@@ -525,7 +554,7 @@ public class ClassFileWriter {
|
||||
addToCodeInt16(theOperand);
|
||||
} else {
|
||||
addToCodeBuffer(theOpCode);
|
||||
addToCodeBuffer((byte)theOperand);
|
||||
addToCodeBuffer(theOperand);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -549,7 +578,7 @@ public class ClassFileWriter {
|
||||
}
|
||||
else {
|
||||
addToCodeBuffer(theOpCode);
|
||||
addToCodeBuffer((byte)theOperand);
|
||||
addToCodeBuffer(theOperand);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -618,7 +647,7 @@ public class ClassFileWriter {
|
||||
* @param theOperand1 the first operand of the bytecode
|
||||
* @param theOperand2 the second operand of the bytecode
|
||||
*/
|
||||
public void add(byte theOpCode, int theOperand1, int theOperand2) {
|
||||
public void add(int theOpCode, int theOperand1, int theOperand2) {
|
||||
if (DEBUGCODE) {
|
||||
System.out.println("Add "+bytecodeStr(theOpCode)
|
||||
+", "+Integer.toHexString(theOperand1)
|
||||
@@ -642,8 +671,8 @@ public class ClassFileWriter {
|
||||
else {
|
||||
addToCodeBuffer(ByteCode.WIDE);
|
||||
addToCodeBuffer(ByteCode.IINC);
|
||||
addToCodeBuffer((byte)theOperand1);
|
||||
addToCodeBuffer((byte)theOperand2);
|
||||
addToCodeBuffer(theOperand1);
|
||||
addToCodeBuffer(theOperand2);
|
||||
}
|
||||
}
|
||||
else if (theOpCode == ByteCode.MULTIANEWARRAY) {
|
||||
@@ -654,7 +683,7 @@ public class ClassFileWriter {
|
||||
|
||||
addToCodeBuffer(ByteCode.MULTIANEWARRAY);
|
||||
addToCodeInt16(theOperand1);
|
||||
addToCodeBuffer((byte)theOperand2);
|
||||
addToCodeBuffer(theOperand2);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException(
|
||||
@@ -669,7 +698,7 @@ public class ClassFileWriter {
|
||||
|
||||
}
|
||||
|
||||
public void add(byte theOpCode, String className) {
|
||||
public void add(int theOpCode, String className) {
|
||||
if (DEBUGCODE) {
|
||||
System.out.println("Add "+bytecodeStr(theOpCode)
|
||||
+", "+className);
|
||||
@@ -700,7 +729,7 @@ public class ClassFileWriter {
|
||||
}
|
||||
|
||||
|
||||
public void add(byte theOpCode, String className, String fieldName,
|
||||
public void add(int theOpCode, String className, String fieldName,
|
||||
String fieldType)
|
||||
{
|
||||
if (DEBUGCODE) {
|
||||
@@ -738,16 +767,7 @@ public class ClassFileWriter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #addInvoke} instead
|
||||
*/
|
||||
public void add(byte theOpCode, String className, String methodName,
|
||||
String parametersType, String returnType)
|
||||
{
|
||||
addInvoke(theOpCode, className, methodName, parametersType+returnType);
|
||||
}
|
||||
|
||||
public void addInvoke(byte theOpCode, String className, String methodName,
|
||||
public void addInvoke(int theOpCode, String className, String methodName,
|
||||
String methodType)
|
||||
{
|
||||
if (DEBUGCODE) {
|
||||
@@ -775,8 +795,8 @@ public class ClassFileWriter {
|
||||
className, methodName,
|
||||
methodType);
|
||||
addToCodeInt16(ifMethodRefIndex);
|
||||
addToCodeBuffer((byte)(parameterCount + 1));
|
||||
addToCodeBuffer((byte)0);
|
||||
addToCodeBuffer(parameterCount + 1);
|
||||
addToCodeBuffer(0);
|
||||
}
|
||||
else {
|
||||
short methodRefIndex = itsConstantPool.addMethodRef(
|
||||
@@ -821,6 +841,11 @@ public class ClassFileWriter {
|
||||
}
|
||||
}
|
||||
|
||||
public void addPush(boolean k)
|
||||
{
|
||||
add(k ? ByteCode.ICONST_1 : ByteCode.ICONST_0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate code to load the given long on stack.
|
||||
*
|
||||
@@ -1022,20 +1047,20 @@ public class ClassFileWriter {
|
||||
add(ByteCode.ALOAD_0);
|
||||
}
|
||||
|
||||
private void xop(byte shortOp, byte op, int local)
|
||||
private void xop(int shortOp, int op, int local)
|
||||
{
|
||||
switch (local) {
|
||||
case 0:
|
||||
add(shortOp);
|
||||
break;
|
||||
case 1:
|
||||
add((byte)(shortOp + 1));
|
||||
add(shortOp + 1);
|
||||
break;
|
||||
case 2:
|
||||
add((byte)(shortOp + 2));
|
||||
add(shortOp + 2);
|
||||
break;
|
||||
case 3:
|
||||
add((byte)(shortOp + 3));
|
||||
add(shortOp + 3);
|
||||
break;
|
||||
default:
|
||||
add(op, local);
|
||||
@@ -1059,7 +1084,7 @@ public class ClassFileWriter {
|
||||
|
||||
int N = addReservedCodeSpace(1 + padSize + 4 * (1 + 2 + entryCount));
|
||||
int switchStart = N;
|
||||
itsCodeBuffer[N++] = ByteCode.TABLESWITCH;
|
||||
itsCodeBuffer[N++] = (byte)ByteCode.TABLESWITCH;
|
||||
while (padSize != 0) {
|
||||
itsCodeBuffer[N++] = 0;
|
||||
--padSize;
|
||||
@@ -1120,7 +1145,7 @@ public class ClassFileWriter {
|
||||
switchStart+" is outside a possible range of tableswitch"
|
||||
+" in already generated code");
|
||||
}
|
||||
if (!(itsCodeBuffer[switchStart] == ByteCode.TABLESWITCH)) {
|
||||
if ((0xFF & itsCodeBuffer[switchStart]) != ByteCode.TABLESWITCH) {
|
||||
throw new IllegalArgumentException(
|
||||
switchStart+" is not offset of tableswitch statement");
|
||||
}
|
||||
@@ -1134,23 +1159,43 @@ public class ClassFileWriter {
|
||||
putInt32(jumpTarget - switchStart, itsCodeBuffer, caseOffset);
|
||||
}
|
||||
|
||||
public int acquireLabel() {
|
||||
return itsLabels.acquireLabel() | 0x80000000;
|
||||
public int acquireLabel()
|
||||
{
|
||||
int top = itsLabelTableTop;
|
||||
if (itsLabelTable == null || top == itsLabelTable.length) {
|
||||
if (itsLabelTable == null) {
|
||||
itsLabelTable = new int[MIN_LABEL_TABLE_SIZE];
|
||||
}else {
|
||||
int[] tmp = new int[itsLabelTable.length * 2];
|
||||
System.arraycopy(itsLabelTable, 0, tmp, 0, top);
|
||||
itsLabelTable = tmp;
|
||||
}
|
||||
}
|
||||
itsLabelTableTop = top + 1;
|
||||
itsLabelTable[top] = -1;
|
||||
return top | 0x80000000;
|
||||
}
|
||||
|
||||
public void markLabel(int label) {
|
||||
if ((label & 0x80000000) != 0x80000000)
|
||||
public void markLabel(int label)
|
||||
{
|
||||
if (!(label < 0))
|
||||
throw new IllegalArgumentException("Bad label, no biscuit");
|
||||
|
||||
itsLabels.markLabel(label & 0x7FFFFFFF, itsCodeBufferTop);
|
||||
label &= 0x7FFFFFFF;
|
||||
if (label > itsLabelTableTop)
|
||||
throw new IllegalArgumentException("Bad label");
|
||||
|
||||
if (itsLabelTable[label] != -1) {
|
||||
throw new IllegalStateException("Can only mark label once");
|
||||
}
|
||||
|
||||
itsLabelTable[label] = itsCodeBufferTop;
|
||||
}
|
||||
|
||||
public void markLabel(int label, short stackTop) {
|
||||
if ((label & 0x80000000) != 0x80000000)
|
||||
throw new IllegalArgumentException("Bad label, no biscuit");
|
||||
|
||||
public void markLabel(int label, short stackTop)
|
||||
{
|
||||
markLabel(label);
|
||||
itsStackTop = stackTop;
|
||||
itsLabels.markLabel(label & 0x7FFFFFFF, itsCodeBufferTop);
|
||||
}
|
||||
|
||||
public void markHandler(int theLabel) {
|
||||
@@ -1158,6 +1203,61 @@ public class ClassFileWriter {
|
||||
markLabel(theLabel);
|
||||
}
|
||||
|
||||
private int getLabelPC(int label)
|
||||
{
|
||||
if (!(label < 0))
|
||||
throw new IllegalArgumentException("Bad label, no biscuit");
|
||||
label &= 0x7FFFFFFF;
|
||||
if (!(label < itsLabelTableTop))
|
||||
throw new IllegalArgumentException("Bad label");
|
||||
return itsLabelTable[label];
|
||||
}
|
||||
|
||||
private void addLabelFixup(int label, int fixupSite)
|
||||
{
|
||||
if (!(label < 0))
|
||||
throw new IllegalArgumentException("Bad label, no biscuit");
|
||||
label &= 0x7FFFFFFF;
|
||||
if (!(label < itsLabelTableTop))
|
||||
throw new IllegalArgumentException("Bad label");
|
||||
int top = itsFixupTableTop;
|
||||
if (itsFixupTable == null || top == itsFixupTable.length) {
|
||||
if (itsFixupTable == null) {
|
||||
itsFixupTable = new long[MIN_FIXUP_TABLE_SIZE];
|
||||
}else {
|
||||
long[] tmp = new long[itsFixupTable.length * 2];
|
||||
System.arraycopy(itsFixupTable, 0, tmp, 0, top);
|
||||
itsFixupTable = tmp;
|
||||
}
|
||||
}
|
||||
itsFixupTableTop = top + 1;
|
||||
itsFixupTable[top] = ((long)label << 32) | fixupSite;
|
||||
}
|
||||
|
||||
private void fixLabelGotos()
|
||||
{
|
||||
byte[] codeBuffer = itsCodeBuffer;
|
||||
for (int i = 0; i < itsFixupTableTop; i++) {
|
||||
long fixup = itsFixupTable[i];
|
||||
int label = (int)(fixup >> 32);
|
||||
int fixupSite = (int)fixup;
|
||||
int pc = itsLabelTable[label];
|
||||
if (pc == -1) {
|
||||
// Unlocated label
|
||||
throw new RuntimeException();
|
||||
}
|
||||
// -1 to get delta from instruction start
|
||||
int offset = pc - (fixupSite - 1);
|
||||
if ((short)offset != offset) {
|
||||
throw new RuntimeException
|
||||
("Program too complex: too big jump offset");
|
||||
}
|
||||
codeBuffer[fixupSite] = (byte)(offset >> 8);
|
||||
codeBuffer[fixupSite + 1] = (byte)offset;
|
||||
}
|
||||
itsFixupTableTop = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current offset into the code of the current method.
|
||||
*
|
||||
@@ -1182,10 +1282,10 @@ public class ClassFileWriter {
|
||||
}
|
||||
}
|
||||
|
||||
private void addToCodeBuffer(byte b)
|
||||
private void addToCodeBuffer(int b)
|
||||
{
|
||||
int N = addReservedCodeSpace(1);
|
||||
itsCodeBuffer[N] = b;
|
||||
itsCodeBuffer[N] = (byte)b;
|
||||
}
|
||||
|
||||
private void addToCodeInt16(int value)
|
||||
@@ -2185,7 +2285,7 @@ public class ClassFileWriter {
|
||||
throw new IllegalArgumentException("Bad opcode: "+opcode);
|
||||
}
|
||||
*/
|
||||
private static String bytecodeStr(byte code)
|
||||
private static String bytecodeStr(int code)
|
||||
{
|
||||
if (DEBUGSTACK || DEBUGCODE) {
|
||||
switch (code) {
|
||||
@@ -2417,7 +2517,6 @@ public class ClassFileWriter {
|
||||
private static final boolean DEBUGSTACK = false;
|
||||
private static final boolean DEBUGLABELS = false;
|
||||
private static final boolean DEBUGCODE = false;
|
||||
private static final int CodeBufferSize = 128;
|
||||
|
||||
private String generatedClassName;
|
||||
|
||||
@@ -2427,13 +2526,11 @@ public class ClassFileWriter {
|
||||
private int itsLineNumberTable[]; // pack start_pc & line_number together
|
||||
private int itsLineNumberTableTop;
|
||||
|
||||
private byte itsCodeBuffer[] = new byte[256];
|
||||
private byte[] itsCodeBuffer = new byte[256];
|
||||
private int itsCodeBufferTop;
|
||||
|
||||
private ConstantPool itsConstantPool;
|
||||
|
||||
private short itsSourceFileAttributeIndex;
|
||||
|
||||
private ClassFileMethod itsCurrentMethod;
|
||||
private short itsStackTop;
|
||||
|
||||
@@ -2449,7 +2546,15 @@ public class ClassFileWriter {
|
||||
private short itsSuperClassIndex;
|
||||
private short itsSourceFileNameIndex;
|
||||
|
||||
private LabelTable itsLabels = new LabelTable();
|
||||
private static final int MIN_LABEL_TABLE_SIZE = 32;
|
||||
private int[] itsLabelTable;
|
||||
private int itsLabelTableTop;
|
||||
|
||||
// itsFixupTable[i] = (label_index << 32) | fixup_site
|
||||
private static final int MIN_FIXUP_TABLE_SIZE = 40;
|
||||
private long[] itsFixupTable;
|
||||
private int itsFixupTableTop;
|
||||
private ObjArray itsVarDescriptors;
|
||||
|
||||
private char[] tmpCharBuffer = new char[64];
|
||||
}
|
||||
@@ -2466,39 +2571,10 @@ final class ExceptionTableEntry
|
||||
itsCatchType = catchType;
|
||||
}
|
||||
|
||||
short getStartPC(LabelTable table)
|
||||
{
|
||||
short pc = (short)table.getLabelPC(itsStartLabel & 0x7FFFFFFF);
|
||||
if (pc == -1)
|
||||
throw new RuntimeException("start label not defined");
|
||||
return pc;
|
||||
}
|
||||
|
||||
short getEndPC(LabelTable table)
|
||||
{
|
||||
short pc = (short)table.getLabelPC(itsEndLabel & 0x7FFFFFFF);
|
||||
if (pc == -1)
|
||||
throw new RuntimeException("end label not defined");
|
||||
return pc;
|
||||
}
|
||||
|
||||
short getHandlerPC(LabelTable table)
|
||||
{
|
||||
short pc = (short)table.getLabelPC(itsHandlerLabel & 0x7FFFFFFF);
|
||||
if (pc == -1)
|
||||
throw new RuntimeException("handler label not defined");
|
||||
return pc;
|
||||
}
|
||||
|
||||
short getCatchType()
|
||||
{
|
||||
return itsCatchType;
|
||||
}
|
||||
|
||||
private int itsStartLabel;
|
||||
private int itsEndLabel;
|
||||
private int itsHandlerLabel;
|
||||
private short itsCatchType;
|
||||
int itsStartLabel;
|
||||
int itsEndLabel;
|
||||
int itsHandlerLabel;
|
||||
short itsCatchType;
|
||||
}
|
||||
|
||||
final class ClassFileField
|
||||
@@ -2890,7 +2966,6 @@ final class ConstantPool
|
||||
private ObjToIntMap itsUtf8Hash = new ObjToIntMap();
|
||||
private ObjToIntMap itsFieldRefHash = new ObjToIntMap();
|
||||
private ObjToIntMap itsMethodRefHash = new ObjToIntMap();
|
||||
private UintMap nameAndTypeHash = new UintMap();
|
||||
private ObjToIntMap itsClassHash = new ObjToIntMap();
|
||||
|
||||
private int itsTop;
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Norris Boyd
|
||||
* Roger Lawrence
|
||||
* Igor Bukanov
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
|
||||
|
||||
package org.mozilla.classfile;
|
||||
|
||||
/**
|
||||
* Information about java variable to use when generating the local
|
||||
* variable table.
|
||||
*/
|
||||
public interface JavaVariable {
|
||||
|
||||
/**
|
||||
* Variable name
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Return variable type as bytecode descriptor string
|
||||
*/
|
||||
public String getTypeDescriptor();
|
||||
|
||||
/**
|
||||
* Return the starting bytecode PC where this variable is live, or -1
|
||||
* if it is not a Java register.
|
||||
*/
|
||||
public int getStartPC();
|
||||
|
||||
/**
|
||||
* Return the Java register number or -1 if it is not a Java register.
|
||||
*/
|
||||
public short getJRegister();
|
||||
}
|
||||
@@ -1,38 +1,41 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Norris Boyd
|
||||
* Igor Bukanov
|
||||
* Norris Boyd
|
||||
* Igor Bukanov
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
package org.mozilla.javascript;
|
||||
|
||||
@@ -44,35 +47,41 @@ package org.mozilla.javascript;
|
||||
* @see org.mozilla.javascript.NativeCall
|
||||
* @author Norris Boyd
|
||||
*/
|
||||
class Arguments extends IdScriptable {
|
||||
final class Arguments extends IdScriptableObject
|
||||
{
|
||||
static final long serialVersionUID = 4275508002492040609L;
|
||||
|
||||
public Arguments(NativeCall activation) {
|
||||
public Arguments(NativeCall activation)
|
||||
{
|
||||
this.activation = activation;
|
||||
|
||||
Scriptable parent = activation.getParentScope();
|
||||
setParentScope(parent);
|
||||
setPrototype(ScriptableObject.getObjectPrototype(parent));
|
||||
|
||||
args = activation.getOriginalArguments();
|
||||
args = activation.originalArgs;
|
||||
lengthObj = new Integer(args.length);
|
||||
|
||||
NativeFunction funObj = activation.funObj;
|
||||
calleeObj = funObj;
|
||||
NativeFunction f = activation.function;
|
||||
calleeObj = f;
|
||||
|
||||
if (funObj.version <= Context.VERSION_1_3
|
||||
&& funObj.version != Context.VERSION_DEFAULT)
|
||||
int version = f.getLanguageVersion();
|
||||
if (version <= Context.VERSION_1_3
|
||||
&& version != Context.VERSION_DEFAULT)
|
||||
{
|
||||
callerObj = null;
|
||||
}else {
|
||||
} else {
|
||||
callerObj = NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
public String getClassName()
|
||||
{
|
||||
return "Arguments";
|
||||
}
|
||||
|
||||
public boolean has(int index, Scriptable start) {
|
||||
public boolean has(int index, Scriptable start)
|
||||
{
|
||||
if (0 <= index && index < args.length) {
|
||||
if (args[index] != NOT_FOUND) {
|
||||
return true;
|
||||
@@ -81,12 +90,14 @@ class Arguments extends IdScriptable {
|
||||
return super.has(index, start);
|
||||
}
|
||||
|
||||
public Object get(int index, Scriptable start) {
|
||||
public Object get(int index, Scriptable start)
|
||||
{
|
||||
if (0 <= index && index < args.length) {
|
||||
Object value = args[index];
|
||||
if (value != NOT_FOUND) {
|
||||
if (sharedWithActivation(index)) {
|
||||
String argName = activation.funObj.argNames[index];
|
||||
NativeFunction f = activation.function;
|
||||
String argName = f.getParamOrVarName(index);
|
||||
value = activation.get(argName, activation);
|
||||
if (value == NOT_FOUND) Kit.codeBug();
|
||||
}
|
||||
@@ -96,16 +107,17 @@ class Arguments extends IdScriptable {
|
||||
return super.get(index, start);
|
||||
}
|
||||
|
||||
private boolean sharedWithActivation(int index) {
|
||||
NativeFunction f = activation.funObj;
|
||||
int definedCount = f.argCount;
|
||||
private boolean sharedWithActivation(int index)
|
||||
{
|
||||
NativeFunction f = activation.function;
|
||||
int definedCount = f.getParamCount();
|
||||
if (index < definedCount) {
|
||||
// Check if argument is not hidden by later argument with the same
|
||||
// name as hidden arguments are not shared with activation
|
||||
if (index < definedCount - 1) {
|
||||
String argName = f.argNames[index];
|
||||
String argName = f.getParamOrVarName(index);
|
||||
for (int i = index + 1; i < definedCount; i++) {
|
||||
if (argName.equals(f.argNames[i])) {
|
||||
if (argName.equals(f.getParamOrVarName(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -115,17 +127,19 @@ class Arguments extends IdScriptable {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void put(int index, Scriptable start, Object value) {
|
||||
public void put(int index, Scriptable start, Object value)
|
||||
{
|
||||
if (0 <= index && index < args.length) {
|
||||
if (args[index] != NOT_FOUND) {
|
||||
if (sharedWithActivation(index)) {
|
||||
String argName = activation.funObj.argNames[index];
|
||||
String argName;
|
||||
argName = activation.function.getParamOrVarName(index);
|
||||
activation.put(argName, activation, value);
|
||||
return;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (args[index] != NOT_FOUND) {
|
||||
if (args == activation.getOriginalArguments()) {
|
||||
if (args == activation.originalArgs) {
|
||||
args = (Object[])args.clone();
|
||||
}
|
||||
args[index] = value;
|
||||
@@ -137,11 +151,12 @@ class Arguments extends IdScriptable {
|
||||
super.put(index, start, value);
|
||||
}
|
||||
|
||||
public void delete(int index) {
|
||||
public void delete(int index)
|
||||
{
|
||||
if (0 <= index && index < args.length) {
|
||||
synchronized (this) {
|
||||
if (args[index] != NOT_FOUND) {
|
||||
if (args == activation.getOriginalArguments()) {
|
||||
if (args == activation.originalArgs) {
|
||||
args = (Object[])args.clone();
|
||||
}
|
||||
args[index] = NOT_FOUND;
|
||||
@@ -152,81 +167,6 @@ class Arguments extends IdScriptable {
|
||||
super.delete(index);
|
||||
}
|
||||
|
||||
protected int getIdAttributes(int id)
|
||||
{
|
||||
switch (id) {
|
||||
case Id_callee:
|
||||
case Id_caller:
|
||||
case Id_length:
|
||||
return DONTENUM;
|
||||
}
|
||||
return super.getIdAttributes(id);
|
||||
}
|
||||
|
||||
protected boolean hasIdValue(int id)
|
||||
{
|
||||
switch (id) {
|
||||
case Id_callee: return calleeObj != NOT_FOUND;
|
||||
case Id_length: return lengthObj != NOT_FOUND;
|
||||
case Id_caller: return callerObj != NOT_FOUND;
|
||||
}
|
||||
return super.hasIdValue(id);
|
||||
}
|
||||
|
||||
protected Object getIdValue(int id)
|
||||
{
|
||||
switch (id) {
|
||||
case Id_callee: return calleeObj;
|
||||
case Id_length: return lengthObj;
|
||||
case Id_caller: {
|
||||
Object value = callerObj;
|
||||
if (value == UniqueTag.NULL_VALUE) { value = null; }
|
||||
else if (value == null) {
|
||||
NativeCall caller = activation.caller;
|
||||
if (caller == null) {
|
||||
value = null;
|
||||
}else {
|
||||
value = caller.get("arguments", caller);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return super.getIdValue(id);
|
||||
}
|
||||
|
||||
protected void setIdValue(int id, Object value)
|
||||
{
|
||||
switch (id) {
|
||||
case Id_callee: calleeObj = value; return;
|
||||
case Id_length: lengthObj = value; return;
|
||||
case Id_caller:
|
||||
callerObj = (value != null) ? value : UniqueTag.NULL_VALUE;
|
||||
return;
|
||||
}
|
||||
super.setIdValue(id, value);
|
||||
}
|
||||
|
||||
protected void deleteIdValue(int id)
|
||||
{
|
||||
switch (id) {
|
||||
case Id_callee: calleeObj = NOT_FOUND; return;
|
||||
case Id_length: lengthObj = NOT_FOUND; return;
|
||||
case Id_caller: callerObj = NOT_FOUND; return;
|
||||
}
|
||||
super.deleteIdValue(id);
|
||||
}
|
||||
|
||||
protected String getIdName(int id)
|
||||
{
|
||||
switch (id) {
|
||||
case Id_callee: return "callee";
|
||||
case Id_length: return "length";
|
||||
case Id_caller: return "caller";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// #string_id_map#
|
||||
|
||||
private static final int
|
||||
@@ -236,9 +176,12 @@ class Arguments extends IdScriptable {
|
||||
|
||||
MAX_INSTANCE_ID = 3;
|
||||
|
||||
{ setMaxId(MAX_INSTANCE_ID); }
|
||||
protected int getMaxInstanceId()
|
||||
{
|
||||
return MAX_INSTANCE_ID;
|
||||
}
|
||||
|
||||
protected int mapNameToId(String s)
|
||||
protected int findInstanceIdInfo(String s)
|
||||
{
|
||||
int id;
|
||||
// #generated# Last update: 2002-04-09 20:46:33 CEST
|
||||
@@ -252,11 +195,102 @@ class Arguments extends IdScriptable {
|
||||
if (X!=null && X!=s && !X.equals(s)) id = 0;
|
||||
}
|
||||
// #/generated#
|
||||
return id;
|
||||
|
||||
if (id == 0) return super.findInstanceIdInfo(s);
|
||||
|
||||
int attr;
|
||||
switch (id) {
|
||||
case Id_callee:
|
||||
case Id_caller:
|
||||
case Id_length:
|
||||
attr = DONTENUM;
|
||||
break;
|
||||
default: throw new IllegalStateException();
|
||||
}
|
||||
return instanceIdInfo(attr, id);
|
||||
}
|
||||
|
||||
// #/string_id_map#
|
||||
|
||||
protected String getInstanceIdName(int id)
|
||||
{
|
||||
switch (id) {
|
||||
case Id_callee: return "callee";
|
||||
case Id_length: return "length";
|
||||
case Id_caller: return "caller";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Object getInstanceIdValue(int id)
|
||||
{
|
||||
switch (id) {
|
||||
case Id_callee: return calleeObj;
|
||||
case Id_length: return lengthObj;
|
||||
case Id_caller: {
|
||||
Object value = callerObj;
|
||||
if (value == UniqueTag.NULL_VALUE) { value = null; }
|
||||
else if (value == null) {
|
||||
NativeCall caller = activation.parentActivationCall;
|
||||
if (caller != null) {
|
||||
value = caller.get("arguments", caller);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return super.getInstanceIdValue(id);
|
||||
}
|
||||
|
||||
protected void setInstanceIdValue(int id, Object value)
|
||||
{
|
||||
switch (id) {
|
||||
case Id_callee: calleeObj = value; return;
|
||||
case Id_length: lengthObj = value; return;
|
||||
case Id_caller:
|
||||
callerObj = (value != null) ? value : UniqueTag.NULL_VALUE;
|
||||
return;
|
||||
}
|
||||
super.setInstanceIdValue(id, value);
|
||||
}
|
||||
|
||||
Object[] getIds(boolean getAll)
|
||||
{
|
||||
Object[] ids = super.getIds(getAll);
|
||||
if (getAll && args.length != 0) {
|
||||
boolean[] present = null;
|
||||
int extraCount = args.length;
|
||||
for (int i = 0; i != ids.length; ++i) {
|
||||
Object id = ids[i];
|
||||
if (id instanceof Integer) {
|
||||
int index = ((Integer)id).intValue();
|
||||
if (0 <= index && index < args.length) {
|
||||
if (present == null) {
|
||||
present = new boolean[args.length];
|
||||
}
|
||||
if (!present[index]) {
|
||||
present[index] = true;
|
||||
extraCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (extraCount != 0) {
|
||||
Object[] tmp = new Object[extraCount + ids.length];
|
||||
System.arraycopy(ids, 0, tmp, extraCount, ids.length);
|
||||
ids = tmp;
|
||||
int offset = 0;
|
||||
for (int i = 0; i != args.length; ++i) {
|
||||
if (present == null || !present[i]) {
|
||||
ids[offset] = new Integer(i);
|
||||
++offset;
|
||||
}
|
||||
}
|
||||
if (offset != extraCount) Kit.codeBug();
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
// Fields to hold caller, callee and length properties,
|
||||
// where NOT_FOUND value tags deleted properties.
|
||||
|
||||
@@ -1,40 +1,43 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Norris Boyd
|
||||
* Igor Bukanov
|
||||
* Roger Lawrence
|
||||
* Mike McCabe
|
||||
* Norris Boyd
|
||||
* Igor Bukanov
|
||||
* Roger Lawrence
|
||||
* Mike McCabe
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
package org.mozilla.javascript;
|
||||
|
||||
@@ -43,23 +46,27 @@ package org.mozilla.javascript;
|
||||
* See ECMA 15.3.
|
||||
* @author Norris Boyd
|
||||
*/
|
||||
public class BaseFunction extends IdScriptable implements Function {
|
||||
public class BaseFunction extends IdScriptableObject implements Function
|
||||
{
|
||||
|
||||
static void init(Context cx, Scriptable scope, boolean sealed) {
|
||||
static final long serialVersionUID = 5311394446546053859L;
|
||||
|
||||
private static final Object FUNCTION_TAG = new Object();
|
||||
|
||||
static void init(Scriptable scope, boolean sealed)
|
||||
{
|
||||
BaseFunction obj = new BaseFunction();
|
||||
obj.prototypeFlag = true;
|
||||
obj.functionName = "";
|
||||
obj.isPrototypePropertyImmune = true;
|
||||
obj.addAsPrototype(MAX_PROTOTYPE_ID, cx, scope, sealed);
|
||||
obj.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed);
|
||||
}
|
||||
|
||||
protected void fillConstructorProperties
|
||||
(Context cx, IdFunction ctor, boolean sealed)
|
||||
public BaseFunction()
|
||||
{
|
||||
// Fix up bootstrapping problem: getPrototype of the IdFunction
|
||||
// can not return Function.prototype because Function object is not
|
||||
// yet defined.
|
||||
ctor.setPrototype(this);
|
||||
}
|
||||
|
||||
public BaseFunction(Scriptable scope, Scriptable prototype)
|
||||
{
|
||||
super(scope, prototype);
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
@@ -83,132 +90,183 @@ public class BaseFunction extends IdScriptable implements Function {
|
||||
public boolean hasInstance(Scriptable instance)
|
||||
{
|
||||
Object protoProp = ScriptableObject.getProperty(this, "prototype");
|
||||
if (protoProp instanceof Scriptable && protoProp != Undefined.instance)
|
||||
{
|
||||
if (protoProp instanceof Scriptable) {
|
||||
return ScriptRuntime.jsDelegatesTo(instance, (Scriptable)protoProp);
|
||||
}
|
||||
throw ScriptRuntime.typeError1("msg.instanceof.bad.prototype",
|
||||
functionName);
|
||||
getFunctionName());
|
||||
}
|
||||
|
||||
protected String toSource(Context cx, Scriptable scope, Object[] args)
|
||||
// #string_id_map#
|
||||
|
||||
private static final int
|
||||
Id_length = 1,
|
||||
Id_arity = 2,
|
||||
Id_name = 3,
|
||||
Id_prototype = 4,
|
||||
Id_arguments = 5,
|
||||
|
||||
MAX_INSTANCE_ID = 5;
|
||||
|
||||
protected int getMaxInstanceId()
|
||||
{
|
||||
int indent = 0;
|
||||
int flags = Decompiler.TO_SOURCE_FLAG;
|
||||
if (args.length != 0) {
|
||||
indent = ScriptRuntime.toInt32(args[0]);
|
||||
if (indent >= 0) {
|
||||
flags = 0;
|
||||
} else {
|
||||
indent = 0;
|
||||
}
|
||||
}
|
||||
return decompile(cx, indent, flags);
|
||||
return MAX_INSTANCE_ID;
|
||||
}
|
||||
|
||||
protected int getIdAttributes(int id)
|
||||
protected int findInstanceIdInfo(String s)
|
||||
{
|
||||
int id;
|
||||
// #generated# Last update: 2001-05-20 00:12:12 GMT+02:00
|
||||
L0: { id = 0; String X = null; int c;
|
||||
L: switch (s.length()) {
|
||||
case 4: X="name";id=Id_name; break L;
|
||||
case 5: X="arity";id=Id_arity; break L;
|
||||
case 6: X="length";id=Id_length; break L;
|
||||
case 9: c=s.charAt(0);
|
||||
if (c=='a') { X="arguments";id=Id_arguments; }
|
||||
else if (c=='p') { X="prototype";id=Id_prototype; }
|
||||
break L;
|
||||
}
|
||||
if (X!=null && X!=s && !X.equals(s)) id = 0;
|
||||
}
|
||||
// #/generated#
|
||||
// #/string_id_map#
|
||||
|
||||
if (id == 0) return super.findInstanceIdInfo(s);
|
||||
|
||||
int attr;
|
||||
switch (id) {
|
||||
case Id_length:
|
||||
case Id_arity:
|
||||
case Id_name:
|
||||
attr = DONTENUM | READONLY | PERMANENT;
|
||||
break;
|
||||
case Id_prototype:
|
||||
attr = (isPrototypePropertyImmune)
|
||||
? READONLY | PERMANENT : PERMANENT;
|
||||
break;
|
||||
case Id_arguments:
|
||||
attr = DONTENUM | PERMANENT;
|
||||
break;
|
||||
default: throw new IllegalStateException();
|
||||
}
|
||||
return instanceIdInfo(attr, id);
|
||||
}
|
||||
|
||||
protected String getInstanceIdName(int id)
|
||||
{
|
||||
switch (id) {
|
||||
case Id_length:
|
||||
case Id_arity:
|
||||
case Id_name:
|
||||
return DONTENUM | READONLY | PERMANENT;
|
||||
case Id_prototype:
|
||||
return isPrototypePropertyImmune
|
||||
? DONTENUM | READONLY | PERMANENT
|
||||
: DONTENUM;
|
||||
case Id_arguments:
|
||||
return EMPTY;
|
||||
case Id_length: return "length";
|
||||
case Id_arity: return "arity";
|
||||
case Id_name: return "name";
|
||||
case Id_prototype: return "prototype";
|
||||
case Id_arguments: return "arguments";
|
||||
}
|
||||
return super.getIdAttributes(id);
|
||||
return super.getInstanceIdName(id);
|
||||
}
|
||||
|
||||
protected boolean hasIdValue(int id)
|
||||
{
|
||||
if (id == Id_prototype) {
|
||||
return prototypeProperty != NOT_FOUND;
|
||||
}
|
||||
else if (id == Id_arguments) {
|
||||
// Should after delete Function.arguments its activation still
|
||||
// be available during Function call?
|
||||
// This code assumes it should not: after default set/deleteIdValue
|
||||
// hasIdValue/getIdValue would not be called again
|
||||
// To handle the opposite case, set/deleteIdValue should be
|
||||
// overwritten as well
|
||||
return null != getActivation(Context.getContext());
|
||||
}
|
||||
return super.hasIdValue(id);
|
||||
}
|
||||
|
||||
protected Object getIdValue(int id)
|
||||
protected Object getInstanceIdValue(int id)
|
||||
{
|
||||
switch (id) {
|
||||
case Id_length: return wrap_int(getLength());
|
||||
case Id_arity: return wrap_int(getArity());
|
||||
case Id_name: return getFunctionName();
|
||||
case Id_prototype: return getPrototypeProperty();
|
||||
case Id_arguments: return getArguments();
|
||||
case Id_length: return ScriptRuntime.wrapInt(getLength());
|
||||
case Id_arity: return ScriptRuntime.wrapInt(getArity());
|
||||
case Id_name: return getFunctionName();
|
||||
case Id_prototype: return getPrototypeProperty();
|
||||
case Id_arguments: return getArguments();
|
||||
}
|
||||
return super.getIdValue(id);
|
||||
return super.getInstanceIdValue(id);
|
||||
}
|
||||
|
||||
protected void setIdValue(int id, Object value)
|
||||
protected void setInstanceIdValue(int id, Object value)
|
||||
{
|
||||
if (id == Id_prototype) {
|
||||
prototypeProperty = (value != null) ? value : UniqueTag.NULL_VALUE;
|
||||
return;
|
||||
}
|
||||
super.setIdValue(id, value);
|
||||
}
|
||||
|
||||
protected void deleteIdValue(int id)
|
||||
{
|
||||
if (id == Id_prototype) {
|
||||
prototypeProperty = NOT_FOUND;
|
||||
return;
|
||||
}
|
||||
super.deleteIdValue(id);
|
||||
}
|
||||
|
||||
public int methodArity(int methodId)
|
||||
{
|
||||
if (prototypeFlag) {
|
||||
switch (methodId) {
|
||||
case Id_constructor: return 1;
|
||||
case Id_toString: return 1;
|
||||
case Id_apply: return 2;
|
||||
case Id_call: return 1;
|
||||
if (!isPrototypePropertyImmune) {
|
||||
prototypeProperty = (value != null)
|
||||
? value : UniqueTag.NULL_VALUE;
|
||||
}
|
||||
return;
|
||||
} else if (id == Id_arguments) {
|
||||
if (value == NOT_FOUND) {
|
||||
// This should not be called since "arguments" is PERMANENT
|
||||
Kit.codeBug();
|
||||
}
|
||||
defaultPut("arguments", value);
|
||||
}
|
||||
return super.methodArity(methodId);
|
||||
super.setInstanceIdValue(id, value);
|
||||
}
|
||||
|
||||
public Object execMethod(int methodId, IdFunction f, Context cx,
|
||||
Scriptable scope, Scriptable thisObj,
|
||||
Object[] args)
|
||||
throws JavaScriptException
|
||||
protected void fillConstructorProperties(IdFunctionObject ctor)
|
||||
{
|
||||
if (prototypeFlag) {
|
||||
switch (methodId) {
|
||||
case Id_constructor:
|
||||
return jsConstructor(cx, scope, args);
|
||||
// Fix up bootstrapping problem: getPrototype of the IdFunctionObject
|
||||
// can not return Function.prototype because Function object is not
|
||||
// yet defined.
|
||||
ctor.setPrototype(this);
|
||||
super.fillConstructorProperties(ctor);
|
||||
}
|
||||
|
||||
case Id_toString: {
|
||||
int indent = ScriptRuntime.toInt32(args, 0);
|
||||
Object x = thisObj.getDefaultValue(ScriptRuntime.FunctionClass);
|
||||
if (x instanceof BaseFunction) {
|
||||
return ((BaseFunction)x).decompile(cx, indent, 0);
|
||||
protected void initPrototypeId(int id)
|
||||
{
|
||||
String s;
|
||||
int arity;
|
||||
switch (id) {
|
||||
case Id_constructor: arity=1; s="constructor"; break;
|
||||
case Id_toString: arity=1; s="toString"; break;
|
||||
case Id_toSource: arity=1; s="toSource"; break;
|
||||
case Id_apply: arity=2; s="apply"; break;
|
||||
case Id_call: arity=1; s="call"; break;
|
||||
default: throw new IllegalArgumentException(String.valueOf(id));
|
||||
}
|
||||
initPrototypeMethod(FUNCTION_TAG, id, s, arity);
|
||||
}
|
||||
|
||||
public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope,
|
||||
Scriptable thisObj, Object[] args)
|
||||
{
|
||||
if (!f.hasTag(FUNCTION_TAG)) {
|
||||
return super.execIdCall(f, cx, scope, thisObj, args);
|
||||
}
|
||||
int id = f.methodId();
|
||||
switch (id) {
|
||||
case Id_constructor:
|
||||
return jsConstructor(cx, scope, args);
|
||||
|
||||
case Id_toString: {
|
||||
BaseFunction realf = realFunction(thisObj, f);
|
||||
int indent = ScriptRuntime.toInt32(args, 0);
|
||||
return realf.decompile(indent, 0);
|
||||
}
|
||||
|
||||
case Id_toSource: {
|
||||
BaseFunction realf = realFunction(thisObj, f);
|
||||
int indent = 0;
|
||||
int flags = Decompiler.TO_SOURCE_FLAG;
|
||||
if (args.length != 0) {
|
||||
indent = ScriptRuntime.toInt32(args[0]);
|
||||
if (indent >= 0) {
|
||||
flags = 0;
|
||||
} else {
|
||||
indent = 0;
|
||||
}
|
||||
throw ScriptRuntime.typeError1("msg.incompat.call", "toString");
|
||||
}
|
||||
|
||||
case Id_apply:
|
||||
case Id_call:
|
||||
return applyOrCall(methodId == Id_apply, cx, scope,
|
||||
thisObj, args);
|
||||
}
|
||||
return realf.decompile(indent, flags);
|
||||
}
|
||||
|
||||
case Id_apply:
|
||||
case Id_call:
|
||||
return ScriptRuntime.applyOrCall(id == Id_apply,
|
||||
cx, scope, thisObj, args);
|
||||
}
|
||||
return super.execMethod(methodId, f, cx, scope, thisObj, args);
|
||||
throw new IllegalArgumentException(String.valueOf(id));
|
||||
}
|
||||
|
||||
private BaseFunction realFunction(Scriptable thisObj, IdFunctionObject f)
|
||||
{
|
||||
Object x = thisObj.getDefaultValue(ScriptRuntime.FunctionClass);
|
||||
if (x instanceof BaseFunction) {
|
||||
return (BaseFunction)x;
|
||||
}
|
||||
throw ScriptRuntime.typeError1("msg.incompat.call",
|
||||
f.getFunctionName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,6 +275,9 @@ public class BaseFunction extends IdScriptable implements Function {
|
||||
*/
|
||||
public void setImmunePrototypeProperty(Object value)
|
||||
{
|
||||
if (isPrototypePropertyImmune) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
prototypeProperty = (value != null) ? value : UniqueTag.NULL_VALUE;
|
||||
isPrototypePropertyImmune = true;
|
||||
}
|
||||
@@ -224,7 +285,7 @@ public class BaseFunction extends IdScriptable implements Function {
|
||||
protected Scriptable getClassPrototype()
|
||||
{
|
||||
Object protoVal = getPrototypeProperty();
|
||||
if (protoVal instanceof Scriptable && protoVal != Undefined.instance) {
|
||||
if (protoVal instanceof Scriptable) {
|
||||
return (Scriptable) protoVal;
|
||||
}
|
||||
return getClassPrototype(this, "Object");
|
||||
@@ -235,28 +296,26 @@ public class BaseFunction extends IdScriptable implements Function {
|
||||
*/
|
||||
public Object call(Context cx, Scriptable scope, Scriptable thisObj,
|
||||
Object[] args)
|
||||
throws JavaScriptException
|
||||
{
|
||||
return Undefined.instance;
|
||||
}
|
||||
|
||||
public Scriptable construct(Context cx, Scriptable scope, Object[] args)
|
||||
throws JavaScriptException
|
||||
{
|
||||
Scriptable result = createObject(cx, scope);
|
||||
if (result != null) {
|
||||
Object val = call(cx, scope, result, args);
|
||||
if (val instanceof Scriptable && val != Undefined.instance) {
|
||||
if (val instanceof Scriptable) {
|
||||
result = (Scriptable)val;
|
||||
}
|
||||
} else {
|
||||
Object val = call(cx, scope, null, args);
|
||||
if (!(val instanceof Scriptable && val != Undefined.instance)) {
|
||||
if (!(val instanceof Scriptable)) {
|
||||
// It is program error not to return Scriptable from
|
||||
// the call method if createObject returns null.
|
||||
throw new IllegalStateException(
|
||||
"Bad implementaion of call as constructor, name="
|
||||
+functionName+" in "+getClass().getName());
|
||||
+getFunctionName()+" in "+getClass().getName());
|
||||
}
|
||||
result = (Scriptable)val;
|
||||
if (result.getPrototype() == null) {
|
||||
@@ -294,13 +353,11 @@ public class BaseFunction extends IdScriptable implements Function {
|
||||
* Decompile the source information associated with this js
|
||||
* function/script back into a string.
|
||||
*
|
||||
* @param cx Current context.
|
||||
*
|
||||
* @param indent How much to indent the decompiled result.
|
||||
*
|
||||
* @param flags Flags specifying format of decompilation output.
|
||||
*/
|
||||
public String decompile(Context cx, int indent, int flags)
|
||||
String decompile(int indent, int flags)
|
||||
{
|
||||
StringBuffer sb = new StringBuffer();
|
||||
boolean justbody = (0 != (flags & Decompiler.ONLY_BODY_FLAG));
|
||||
@@ -322,13 +379,12 @@ public class BaseFunction extends IdScriptable implements Function {
|
||||
|
||||
public int getLength() { return 0; }
|
||||
|
||||
public String getFunctionName() {
|
||||
if (functionName == null)
|
||||
return "";
|
||||
return functionName;
|
||||
public String getFunctionName()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
private Object getPrototypeProperty() {
|
||||
final Object getPrototypeProperty() {
|
||||
Object result = prototypeProperty;
|
||||
if (result == null) {
|
||||
synchronized (this) {
|
||||
@@ -346,9 +402,7 @@ public class BaseFunction extends IdScriptable implements Function {
|
||||
private void setupDefaultPrototype()
|
||||
{
|
||||
NativeObject obj = new NativeObject();
|
||||
final int attr = ScriptableObject.DONTENUM |
|
||||
ScriptableObject.READONLY |
|
||||
ScriptableObject.PERMANENT;
|
||||
final int attr = ScriptableObject.DONTENUM;
|
||||
obj.defineProperty("constructor", this, attr);
|
||||
// put the prototype property into the object now, then in the
|
||||
// wacky case of a user defining a function Object(), we don't
|
||||
@@ -363,24 +417,23 @@ public class BaseFunction extends IdScriptable implements Function {
|
||||
|
||||
private Object getArguments()
|
||||
{
|
||||
// <Function name>.arguments is deprecated, so we use a slow
|
||||
// way of getting it that doesn't add to the invocation cost.
|
||||
// TODO: add warning, error based on version
|
||||
NativeCall activation = getActivation(Context.getContext());
|
||||
return activation == null
|
||||
? null
|
||||
: activation.get("arguments", activation);
|
||||
}
|
||||
|
||||
NativeCall getActivation(Context cx)
|
||||
{
|
||||
NativeCall activation = cx.currentActivation;
|
||||
while (activation != null) {
|
||||
if (activation.getFunctionObject() == this)
|
||||
return activation;
|
||||
activation = activation.caller;
|
||||
}
|
||||
return null;
|
||||
// <Function name>.arguments is deprecated, so we use a slow
|
||||
// way of getting it that doesn't add to the invocation cost.
|
||||
// TODO: add warning, error based on version
|
||||
Object value = defaultGet("arguments");
|
||||
if (value != NOT_FOUND) {
|
||||
// Should after changing <Function name>.arguments its
|
||||
// activation still be available during Function call?
|
||||
// This code assumes it should not:
|
||||
// defaultGet("arguments") != NOT_FOUND
|
||||
// means assigned arguments
|
||||
return value;
|
||||
}
|
||||
Context cx = Context.getContext();
|
||||
NativeCall activation = ScriptRuntime.findFunctionActivation(cx, this);
|
||||
return (activation == null)
|
||||
? null
|
||||
: activation.get("arguments", activation);
|
||||
}
|
||||
|
||||
private static Object jsConstructor(Context cx, Scriptable scope,
|
||||
@@ -424,140 +477,33 @@ public class BaseFunction extends IdScriptable implements Function {
|
||||
linep[0] = 1;
|
||||
}
|
||||
|
||||
String sourceName = ScriptRuntime.
|
||||
String sourceURI = ScriptRuntime.
|
||||
makeUrlForGeneratedScript(false, filename, linep[0]);
|
||||
|
||||
Scriptable global = ScriptableObject.getTopLevelScope(scope);
|
||||
|
||||
// Compile the function with opt level of -1 to force interpreter
|
||||
ErrorReporter reporter;
|
||||
reporter = DefaultErrorReporter.forEval(cx.getErrorReporter());
|
||||
|
||||
// Compile with explicit interpreter instance to force interpreter
|
||||
// mode.
|
||||
int oldOptLevel = cx.getOptimizationLevel();
|
||||
cx.setOptimizationLevel(-1);
|
||||
NativeFunction fn;
|
||||
try {
|
||||
fn = (NativeFunction) cx.compileFunction(global, source,
|
||||
sourceName, 1,
|
||||
null);
|
||||
}
|
||||
finally { cx.setOptimizationLevel(oldOptLevel); }
|
||||
|
||||
ScriptRuntime.setFunctionProtoAndParent(global, fn);
|
||||
|
||||
return fn;
|
||||
return cx.compileFunction(global, source, new Interpreter(), reporter,
|
||||
sourceURI, 1, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function.prototype.apply and Function.prototype.call
|
||||
*
|
||||
* See Ecma 15.3.4.[34]
|
||||
*/
|
||||
private static Object applyOrCall(boolean isApply,
|
||||
Context cx, Scriptable scope,
|
||||
Scriptable thisObj, Object[] args)
|
||||
throws JavaScriptException
|
||||
{
|
||||
int L = args.length;
|
||||
Object function = thisObj.getDefaultValue(ScriptRuntime.FunctionClass);
|
||||
|
||||
Object callThis;
|
||||
if (L == 0 || args[0] == null || args[0] == Undefined.instance) {
|
||||
callThis = ScriptableObject.getTopLevelScope(scope);
|
||||
} else {
|
||||
callThis = ScriptRuntime.toObject(cx, scope, args[0]);
|
||||
}
|
||||
|
||||
Object[] callArgs;
|
||||
if (isApply) {
|
||||
// Follow Ecma 15.3.4.3
|
||||
if (L <= 1) {
|
||||
callArgs = ScriptRuntime.emptyArgs;
|
||||
} else {
|
||||
Object arg1 = args[1];
|
||||
if (arg1 == null || arg1 == Undefined.instance) {
|
||||
callArgs = ScriptRuntime.emptyArgs;
|
||||
} else if (arg1 instanceof NativeArray
|
||||
|| arg1 instanceof Arguments)
|
||||
{
|
||||
callArgs = cx.getElements((Scriptable) arg1);
|
||||
} else {
|
||||
throw ScriptRuntime.typeError0("msg.arg.isnt.array");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Follow Ecma 15.3.4.4
|
||||
if (L <= 1) {
|
||||
callArgs = ScriptRuntime.emptyArgs;
|
||||
} else {
|
||||
callArgs = new Object[L - 1];
|
||||
System.arraycopy(args, 1, callArgs, 0, L - 1);
|
||||
}
|
||||
}
|
||||
|
||||
return ScriptRuntime.call(cx, function, callThis, callArgs, scope);
|
||||
}
|
||||
|
||||
protected String getIdName(int id)
|
||||
{
|
||||
switch (id) {
|
||||
case Id_length: return "length";
|
||||
case Id_arity: return "arity";
|
||||
case Id_name: return "name";
|
||||
case Id_prototype: return "prototype";
|
||||
case Id_arguments: return "arguments";
|
||||
}
|
||||
|
||||
if (prototypeFlag) {
|
||||
switch (id) {
|
||||
case Id_constructor: return "constructor";
|
||||
case Id_toString: return "toString";
|
||||
case Id_apply: return "apply";
|
||||
case Id_call: return "call";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// #string_id_map#
|
||||
|
||||
private static final int
|
||||
Id_length = 1,
|
||||
Id_arity = 2,
|
||||
Id_name = 3,
|
||||
Id_prototype = 4,
|
||||
Id_arguments = 5,
|
||||
|
||||
MAX_INSTANCE_ID = 5;
|
||||
|
||||
{ setMaxId(MAX_INSTANCE_ID); }
|
||||
|
||||
protected int mapNameToId(String s)
|
||||
protected int findPrototypeId(String s)
|
||||
{
|
||||
int id;
|
||||
// #generated# Last update: 2001-05-20 00:12:12 GMT+02:00
|
||||
L0: { id = 0; String X = null; int c;
|
||||
L: switch (s.length()) {
|
||||
case 4: X="name";id=Id_name; break L;
|
||||
case 5: X="arity";id=Id_arity; break L;
|
||||
case 6: X="length";id=Id_length; break L;
|
||||
case 9: c=s.charAt(0);
|
||||
if (c=='a') { X="arguments";id=Id_arguments; }
|
||||
else if (c=='p') { X="prototype";id=Id_prototype; }
|
||||
break L;
|
||||
}
|
||||
if (X!=null && X!=s && !X.equals(s)) id = 0;
|
||||
}
|
||||
// #/generated#
|
||||
// #/string_id_map#
|
||||
|
||||
if (id != 0 || !prototypeFlag) { return id; }
|
||||
|
||||
// #string_id_map#
|
||||
// #generated# Last update: 2001-05-20 00:12:12 GMT+02:00
|
||||
L0: { id = 0; String X = null;
|
||||
// #generated# Last update: 2004-03-17 13:23:22 CET
|
||||
L0: { id = 0; String X = null; int c;
|
||||
L: switch (s.length()) {
|
||||
case 4: X="call";id=Id_call; break L;
|
||||
case 5: X="apply";id=Id_apply; break L;
|
||||
case 8: X="toString";id=Id_toString; break L;
|
||||
case 8: c=s.charAt(3);
|
||||
if (c=='o') { X="toSource";id=Id_toSource; }
|
||||
else if (c=='t') { X="toString";id=Id_toString; }
|
||||
break L;
|
||||
case 11: X="constructor";id=Id_constructor; break L;
|
||||
}
|
||||
if (X!=null && X!=s && !X.equals(s)) id = 0;
|
||||
@@ -567,19 +513,17 @@ public class BaseFunction extends IdScriptable implements Function {
|
||||
}
|
||||
|
||||
private static final int
|
||||
Id_constructor = MAX_INSTANCE_ID + 1,
|
||||
Id_toString = MAX_INSTANCE_ID + 2,
|
||||
Id_apply = MAX_INSTANCE_ID + 3,
|
||||
Id_call = MAX_INSTANCE_ID + 4,
|
||||
Id_constructor = 1,
|
||||
Id_toString = 2,
|
||||
Id_toSource = 3,
|
||||
Id_apply = 4,
|
||||
Id_call = 5,
|
||||
|
||||
MAX_PROTOTYPE_ID = MAX_INSTANCE_ID + 4;
|
||||
MAX_PROTOTYPE_ID = 5;
|
||||
|
||||
// #/string_id_map#
|
||||
|
||||
protected String functionName;
|
||||
|
||||
private Object prototypeProperty;
|
||||
private boolean isPrototypePropertyImmune;
|
||||
private boolean prototypeFlag;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
@@ -13,27 +13,26 @@
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is interface specifiing callable object to execute script
|
||||
* related code on demand.
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* RUnit Software AS.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Igor Bukanov, igor@fastmail.fm
|
||||
* Contributor(s):
|
||||
* Igor Bukanov, igor@fastmail.fm
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
@@ -53,11 +52,8 @@ public interface Callable
|
||||
* @param thisObj the JavaScript <code>this</code> object
|
||||
* @param args the array of arguments
|
||||
* @return the result of the call
|
||||
* @exception JavaScriptException if an uncaught exception
|
||||
* occurred while executing the function
|
||||
*/
|
||||
public Object call(Context cx, Scriptable scope, Scriptable thisObj,
|
||||
Object[] args)
|
||||
throws JavaScriptException;
|
||||
Object[] args);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
@@ -13,32 +13,31 @@
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is cache holder of generated code for Java reflection
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* RUnit Software AS.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Igor Bukanov, igor@fastmail.fm
|
||||
* Contributor(s):
|
||||
* Igor Bukanov, igor@fastmail.fm
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
package org.mozilla.javascript;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Hashtable;
|
||||
|
||||
/**
|
||||
@@ -57,12 +56,11 @@ public class ClassCache
|
||||
|
||||
Hashtable classTable = new Hashtable();
|
||||
|
||||
boolean invokerOptimization = true;
|
||||
Invoker invokerMaster;
|
||||
|
||||
Hashtable javaAdapterGeneratedClasses = new Hashtable();
|
||||
|
||||
Hashtable javaAdapterIFGlueMasters = new Hashtable();
|
||||
ScriptableObject scope;
|
||||
|
||||
private Hashtable interfaceAdapterCache;
|
||||
|
||||
private int generatedClassSerial;
|
||||
|
||||
@@ -81,21 +79,13 @@ public class ClassCache
|
||||
*/
|
||||
public static ClassCache get(Scriptable scope)
|
||||
{
|
||||
scope = ScriptableObject.getTopLevelScope(scope);
|
||||
Scriptable obj = scope;
|
||||
do {
|
||||
if (obj instanceof ScriptableObject) {
|
||||
ScriptableObject so = (ScriptableObject)obj;
|
||||
ClassCache lc = (ClassCache)so.getAssociatedValue(AKEY);
|
||||
if (lc != null) {
|
||||
return lc;
|
||||
}
|
||||
}
|
||||
obj = obj.getPrototype();
|
||||
} while (obj != null);
|
||||
|
||||
// ALERT: warn somehow about wrong cache usage ?
|
||||
return new ClassCache();
|
||||
ClassCache cache;
|
||||
cache = (ClassCache)ScriptableObject.getTopScopeValue(scope, AKEY);
|
||||
if (cache == null) {
|
||||
// XXX warn somehow about wrong cache usage ?
|
||||
cache = new ClassCache();
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,7 +105,11 @@ public class ClassCache
|
||||
// Can only associate cache with top level scope
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
return this != topScope.associateValue(AKEY, this);
|
||||
if(this == topScope.associateValue(AKEY, this)) {
|
||||
scope = topScope;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,11 +119,7 @@ public class ClassCache
|
||||
{
|
||||
classTable = new Hashtable();
|
||||
javaAdapterGeneratedClasses = new Hashtable();
|
||||
javaAdapterIFGlueMasters = new Hashtable();
|
||||
Invoker im = invokerMaster;
|
||||
if (im != null) {
|
||||
im.clearMasterCaches();
|
||||
}
|
||||
interfaceAdapterCache = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,8 +134,8 @@ public class ClassCache
|
||||
/**
|
||||
* Set whether to cache some values.
|
||||
* <p>
|
||||
* By default, the engine will cache generated classes and
|
||||
* results of <tt>Class.getMethods()</tt> and similar calls.
|
||||
* By default, the engine will cache the results of
|
||||
* <tt>Class.getMethods()</tt> and similar calls.
|
||||
* This can speed execution dramatically, but increases the memory
|
||||
* footprint. Also, with caching enabled, references may be held to
|
||||
* objects past the lifetime of any real usage.
|
||||
@@ -155,7 +145,7 @@ public class ClassCache
|
||||
* <p>
|
||||
* Caching is enabled by default.
|
||||
*
|
||||
* @param cachingEnabled if true, caching is enabled
|
||||
* @param enabled if true, caching is enabled
|
||||
*
|
||||
* @see #clearCaches()
|
||||
*/
|
||||
@@ -169,23 +159,26 @@ public class ClassCache
|
||||
}
|
||||
|
||||
/**
|
||||
* To optimize invocation of reflected Java methods, the engine generates
|
||||
* special glue classes that will call the methods directly. By default
|
||||
* the optimization is enabled since it allows to speedup method invocation
|
||||
* compared with calling <tt>Method.invoke</tt> by factor 2-2.5 under JDK
|
||||
* 1.4.2 and by factor 10-15 under JDK 1.3.1. If increase memory
|
||||
* consumption is too high or the optimization brings no benefits in a
|
||||
* particular VM, then the optimization can be disabled.
|
||||
*
|
||||
* @param enabled if true, invoke optimization is enabled.
|
||||
* @deprecated
|
||||
* The method always returns false.
|
||||
* @see #setInvokerOptimizationEnabled(boolean enabled)
|
||||
*/
|
||||
public boolean isInvokerOptimizationEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* The method does nothing.
|
||||
* Invoker optimization is no longer used by Rhino.
|
||||
* On modern JDK like 1.4 or 1.5 the disadvatages of the optimization
|
||||
* like incresed memory usage or longer initialization time overweight
|
||||
* small speed increase that can be gained using generated proxy class
|
||||
* to replace reflection.
|
||||
*/
|
||||
public synchronized void setInvokerOptimizationEnabled(boolean enabled)
|
||||
{
|
||||
if (invokerOptimization == enabled)
|
||||
return;
|
||||
if (!enabled)
|
||||
invokerMaster = null;
|
||||
invokerOptimization = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,4 +189,26 @@ public class ClassCache
|
||||
{
|
||||
return ++generatedClassSerial;
|
||||
}
|
||||
|
||||
Object getInterfaceAdapter(Class cl)
|
||||
{
|
||||
Object result;
|
||||
Hashtable cache = interfaceAdapterCache;
|
||||
if (cache == null) {
|
||||
result = null;
|
||||
} else {
|
||||
result = cache.get(cl);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
synchronized void cacheInterfaceAdapter(Class cl, Object iadapter)
|
||||
{
|
||||
if (cachingIsEnabled) {
|
||||
if (interfaceAdapterCache == null) {
|
||||
interfaceAdapterCache = new Hashtable();
|
||||
}
|
||||
interfaceAdapterCache.put(cl, iadapter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
// API class
|
||||
|
||||
package org.mozilla.javascript;
|
||||
|
||||
/**
|
||||
* Thrown if errors are detected while attempting to define a host object
|
||||
* from a Java class.
|
||||
*/
|
||||
public class ClassDefinitionException extends Exception {
|
||||
|
||||
public ClassDefinitionException(String detail) {
|
||||
super(detail);
|
||||
}
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Norris Boyd
|
||||
* Roger Lawrence
|
||||
* Andi Vajda
|
||||
* Kemal Bayram
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
|
||||
package org.mozilla.javascript;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public abstract class ClassNameHelper {
|
||||
|
||||
public static ClassNameHelper get(Context cx) {
|
||||
ClassNameHelper helper = savedNameHelper;
|
||||
if (helper == null && !helperNotAvailable) {
|
||||
Class nameHelperClass = Kit.classOrNull(
|
||||
"org.mozilla.javascript.optimizer.OptClassNameHelper");
|
||||
// nameHelperClass == null if running lite
|
||||
if (nameHelperClass != null) {
|
||||
helper = (ClassNameHelper)Kit.newInstanceOrNull(
|
||||
nameHelperClass);
|
||||
}
|
||||
if (helper != null) {
|
||||
savedNameHelper = helper;
|
||||
} else {
|
||||
helperNotAvailable = true;
|
||||
}
|
||||
}
|
||||
return helper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current target class file name.
|
||||
* <p>
|
||||
* If nonnull, requests to compile source will result in one or
|
||||
* more class files being generated.
|
||||
*
|
||||
* @since 1.5 Release 4
|
||||
*/
|
||||
public abstract String getTargetClassFileName();
|
||||
|
||||
/**
|
||||
* Set the current target class file name.
|
||||
* <p>
|
||||
* If nonnull, requests to compile source will result in one or
|
||||
* more class files being generated. If null, classes will only
|
||||
* be generated in memory.
|
||||
*
|
||||
* @since 1.5 Release 4
|
||||
*/
|
||||
public abstract void setTargetClassFileName(String classFileName);
|
||||
|
||||
/**
|
||||
* Get the current package to generate classes into.
|
||||
*/
|
||||
public abstract String getTargetPackage();
|
||||
|
||||
/**
|
||||
* Set the package to generate classes into.
|
||||
*/
|
||||
public abstract void setTargetPackage(String targetPackage);
|
||||
|
||||
/**
|
||||
* Set the class that the generated target will extend.
|
||||
*
|
||||
* @param extendsClass the class it extends
|
||||
*/
|
||||
public abstract void setTargetExtends(Class extendsClass);
|
||||
|
||||
/**
|
||||
* Set the interfaces that the generated target will implement.
|
||||
*
|
||||
* @param implementsClasses an array of Class objects, one for each
|
||||
* interface the target will extend
|
||||
*/
|
||||
public abstract void setTargetImplements(Class[] implementsClasses);
|
||||
|
||||
/**
|
||||
* Get the current class repository.
|
||||
*
|
||||
* @see ClassRepository
|
||||
* @since 30/10/01 tip + patch (Kemal Bayram)
|
||||
*/
|
||||
public abstract ClassRepository getClassRepository();
|
||||
|
||||
/**
|
||||
* Set the current class repository.
|
||||
*
|
||||
* @see ClassRepository
|
||||
* @since 30/10/01 tip + patch (Kemal Bayram)
|
||||
*/
|
||||
public abstract void setClassRepository(ClassRepository repository);
|
||||
|
||||
/**
|
||||
* Get the current class name.
|
||||
*
|
||||
* @since 30/10/01 tip + patch (Kemal Bayram)
|
||||
*/
|
||||
public abstract String getClassName();
|
||||
|
||||
/**
|
||||
* Set the current class name.
|
||||
*
|
||||
* @since 30/10/01 tip + patch (Kemal Bayram)
|
||||
*/
|
||||
public abstract void setClassName(String initialName);
|
||||
|
||||
private static ClassNameHelper savedNameHelper;
|
||||
private static boolean helperNotAvailable;
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Kemal Bayram
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
package org.mozilla.javascript;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* This interface provides a means to store generated class and to
|
||||
* allow selective class loading.
|
||||
*
|
||||
* @see ClassNameHelper
|
||||
* @author Kemal Bayram
|
||||
*/
|
||||
public interface ClassRepository {
|
||||
/**
|
||||
* @param className the name of the class.
|
||||
* @param classBytes a byte array of the generated class.
|
||||
* @param isTopLevel if true, represents the top-level script being compiled.
|
||||
* @return true if the class should be loaded, false otherwise.
|
||||
*/
|
||||
public boolean storeClass(String className, byte[] classBytes,
|
||||
boolean isTopLevel) throws IOException;
|
||||
}
|
||||
@@ -1,38 +1,41 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Norris Boyd
|
||||
* Igor Bukanov
|
||||
* Norris Boyd
|
||||
* Igor Bukanov
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// API class
|
||||
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Bukanov, igor@fastmail.fm
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
package org.mozilla.javascript;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
public class CompilerEnvirons
|
||||
{
|
||||
public CompilerEnvirons()
|
||||
{
|
||||
errorReporter = DefaultErrorReporter.instance;
|
||||
languageVersion = Context.VERSION_DEFAULT;
|
||||
generateDebugInfo = true;
|
||||
useDynamicScope = false;
|
||||
reservedKeywordAsIdentifier = false;
|
||||
allowMemberExprAsFunctionName = false;
|
||||
xmlAvailable = true;
|
||||
optimizationLevel = 0;
|
||||
generatingSource = true;
|
||||
}
|
||||
|
||||
public void initFromContext(Context cx)
|
||||
{
|
||||
setErrorReporter(cx.getErrorReporter());
|
||||
this.languageVersion = cx.getLanguageVersion();
|
||||
useDynamicScope = cx.compileFunctionsWithDynamicScopeFlag;
|
||||
generateDebugInfo = (!cx.isGeneratingDebugChanged()
|
||||
|| cx.isGeneratingDebug());
|
||||
reservedKeywordAsIdentifier
|
||||
= cx.hasFeature(Context.FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER);
|
||||
allowMemberExprAsFunctionName
|
||||
= cx.hasFeature(Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME);
|
||||
xmlAvailable
|
||||
= cx.hasFeature(Context.FEATURE_E4X);
|
||||
|
||||
optimizationLevel = cx.getOptimizationLevel();
|
||||
|
||||
generatingSource = cx.isGeneratingSource();
|
||||
activationNames = cx.activationNames;
|
||||
}
|
||||
|
||||
public final ErrorReporter getErrorReporter()
|
||||
{
|
||||
return errorReporter;
|
||||
}
|
||||
|
||||
public void setErrorReporter(ErrorReporter errorReporter)
|
||||
{
|
||||
if (errorReporter == null) throw new IllegalArgumentException();
|
||||
this.errorReporter = errorReporter;
|
||||
}
|
||||
|
||||
public final int getLanguageVersion()
|
||||
{
|
||||
return languageVersion;
|
||||
}
|
||||
|
||||
public void setLanguageVersion(int languageVersion)
|
||||
{
|
||||
Context.checkLanguageVersion(languageVersion);
|
||||
this.languageVersion = languageVersion;
|
||||
}
|
||||
|
||||
public final boolean isGenerateDebugInfo()
|
||||
{
|
||||
return generateDebugInfo;
|
||||
}
|
||||
|
||||
public void setGenerateDebugInfo(boolean flag)
|
||||
{
|
||||
this.generateDebugInfo = flag;
|
||||
}
|
||||
|
||||
public final boolean isUseDynamicScope()
|
||||
{
|
||||
return useDynamicScope;
|
||||
}
|
||||
|
||||
public final boolean isReservedKeywordAsIdentifier()
|
||||
{
|
||||
return reservedKeywordAsIdentifier;
|
||||
}
|
||||
|
||||
public void setReservedKeywordAsIdentifier(boolean flag)
|
||||
{
|
||||
reservedKeywordAsIdentifier = flag;
|
||||
}
|
||||
|
||||
public final boolean isAllowMemberExprAsFunctionName()
|
||||
{
|
||||
return allowMemberExprAsFunctionName;
|
||||
}
|
||||
|
||||
public void setAllowMemberExprAsFunctionName(boolean flag)
|
||||
{
|
||||
allowMemberExprAsFunctionName = flag;
|
||||
}
|
||||
|
||||
public final boolean isXmlAvailable()
|
||||
{
|
||||
return xmlAvailable;
|
||||
}
|
||||
|
||||
public void setXmlAvailable(boolean flag)
|
||||
{
|
||||
xmlAvailable = flag;
|
||||
}
|
||||
|
||||
public final int getOptimizationLevel()
|
||||
{
|
||||
return optimizationLevel;
|
||||
}
|
||||
|
||||
public void setOptimizationLevel(int level)
|
||||
{
|
||||
Context.checkOptimizationLevel(level);
|
||||
this.optimizationLevel = level;
|
||||
}
|
||||
|
||||
public final boolean isGeneratingSource()
|
||||
{
|
||||
return generatingSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify whether or not source information should be generated.
|
||||
* <p>
|
||||
* 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.
|
||||
*/
|
||||
public void setGeneratingSource(boolean generatingSource)
|
||||
{
|
||||
this.generatingSource = generatingSource;
|
||||
}
|
||||
|
||||
private ErrorReporter errorReporter;
|
||||
|
||||
private int languageVersion;
|
||||
private boolean generateDebugInfo;
|
||||
private boolean useDynamicScope;
|
||||
private boolean reservedKeywordAsIdentifier;
|
||||
private boolean allowMemberExprAsFunctionName;
|
||||
private boolean xmlAvailable;
|
||||
private int optimizationLevel;
|
||||
private boolean generatingSource;
|
||||
Hashtable activationNames;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,59 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Bukanov, igor@fastmail.fm
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// API class
|
||||
|
||||
package org.mozilla.javascript;
|
||||
|
||||
/**
|
||||
* Interface to represent arbitrary action that requires to have Context
|
||||
* object associated with the current thread for its execution.
|
||||
*/
|
||||
public interface ContextAction
|
||||
{
|
||||
/**
|
||||
* Execute action using the supplied Context instance.
|
||||
* When Rhino runtime calls the method, <tt>cx</tt> will be associated
|
||||
* with the current thread as active context.
|
||||
*
|
||||
* @see Context#call(ContextAction)
|
||||
* @see ContextFactory#call(ContextAction)
|
||||
*/
|
||||
public Object run(Context cx);
|
||||
}
|
||||
|
||||
488
mozilla/js/rhino/src/org/mozilla/javascript/ContextFactory.java
Normal file
488
mozilla/js/rhino/src/org/mozilla/javascript/ContextFactory.java
Normal file
@@ -0,0 +1,488 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Bukanov, igor@fastmail.fm
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// API class
|
||||
|
||||
package org.mozilla.javascript;
|
||||
|
||||
/**
|
||||
* Factory class that Rhino runtime use to create new {@link Context}
|
||||
* instances or to notify about Context execution.
|
||||
* <p>
|
||||
* When Rhino runtime needs to create new {@link Context} instance during
|
||||
* execution of {@link Context#enter()} or {@link Context}, it will call
|
||||
* {@link #makeContext()} of the current global ContextFactory.
|
||||
* See {@link #getGlobal()} and {@link #initGlobal(ContextFactory)}.
|
||||
* <p>
|
||||
* It is also possible to use explicit ContextFactory instances for Context
|
||||
* creation. This is useful to have a set of independent Rhino runtime
|
||||
* instances under single JVM. See {@link #call(ContextAction)}.
|
||||
* <p>
|
||||
* The following example demonstrates Context customization to terminate
|
||||
* scripts running more then 10 seconds and to provide better compatibility
|
||||
* with JavaScript code using MSIE-specific features.
|
||||
* <pre>
|
||||
* import org.mozilla.javascript.*;
|
||||
*
|
||||
* class MyFactory extends ContextFactory
|
||||
* {
|
||||
*
|
||||
* // Custom {@link Context} to store execution time.
|
||||
* private static class MyContext extends Context
|
||||
* {
|
||||
* long startTime;
|
||||
* }
|
||||
*
|
||||
* static {
|
||||
* // Initialize GlobalFactory with custom factory
|
||||
* ContextFactory.initGlobal(new MyFactory());
|
||||
* }
|
||||
*
|
||||
* // Override {@link #makeContext()}
|
||||
* protected Context makeContext()
|
||||
* {
|
||||
* MyContext cx = new MyContext();
|
||||
* // Use pure interpreter mode to allow for
|
||||
* // {@link #observeInstructionCount(Context, int)} to work
|
||||
* cx.setOptimizationLevel(-1);
|
||||
* // Make Rhino runtime to call observeInstructionCount
|
||||
* // each 10000 bytecode instructions
|
||||
* cx.setInstructionObserverThreshold(10000);
|
||||
* return cx;
|
||||
* }
|
||||
*
|
||||
* // Override {@link #hasFeature(Context, int)}
|
||||
* public boolean hasFeature(Context cx, int featureIndex)
|
||||
* {
|
||||
* // Turn on maximum compatibility with MSIE scripts
|
||||
* switch (featureIndex) {
|
||||
* case {@link Context#FEATURE_NON_ECMA_GET_YEAR}:
|
||||
* return true;
|
||||
*
|
||||
* case {@link Context#FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME}:
|
||||
* return true;
|
||||
*
|
||||
* case {@link Context#FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER}:
|
||||
* return true;
|
||||
*
|
||||
* case {@link Context#FEATURE_PARENT_PROTO_PROPERTIES}:
|
||||
* return false;
|
||||
* }
|
||||
* return super.hasFeature(cx, featureIndex);
|
||||
* }
|
||||
*
|
||||
* // Override {@link #observeInstructionCount(Context, int)}
|
||||
* protected void observeInstructionCount(Context cx, int instructionCount)
|
||||
* {
|
||||
* MyContext mcx = (MyContext)cx;
|
||||
* long currentTime = System.currentTimeMillis();
|
||||
* if (currentTime - mcx.startTime > 10*1000) {
|
||||
* // More then 10 seconds from Context creation time:
|
||||
* // it is time to stop the script.
|
||||
* // Throw Error instance to ensure that script will never
|
||||
* // get control back through catch or finally.
|
||||
* throw new Error();
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* // Override {@link #doTopCall(Callable, Context, Scriptable scope, Scriptable thisObj, Object[] args)}
|
||||
* protected Object doTopCall(Callable callable,
|
||||
* Context cx, Scriptable scope,
|
||||
* Scriptable thisObj, Object[] args)
|
||||
* {
|
||||
* MyContext mcx = (MyContext)cx;
|
||||
* mcx.startTime = System.currentTimeMillis();
|
||||
*
|
||||
* return super.doTopCall(callable, cx, scope, thisObj, args);
|
||||
* }
|
||||
*
|
||||
* }
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
public class ContextFactory
|
||||
{
|
||||
private static volatile boolean hasCustomGlobal;
|
||||
private static ContextFactory global = new ContextFactory();
|
||||
|
||||
private volatile boolean sealed;
|
||||
|
||||
private final Object listenersLock = new Object();
|
||||
private volatile Object listeners;
|
||||
private boolean disabledListening;
|
||||
private ClassLoader applicationClassLoader;
|
||||
|
||||
/**
|
||||
* Listener of {@link Context} creation and release events.
|
||||
*/
|
||||
public interface Listener
|
||||
{
|
||||
/**
|
||||
* Notify about newly created {@link Context} object.
|
||||
*/
|
||||
public void contextCreated(Context cx);
|
||||
|
||||
/**
|
||||
* Notify that the specified {@link Context} instance is no longer
|
||||
* associated with the current thread.
|
||||
*/
|
||||
public void contextReleased(Context cx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get global ContextFactory.
|
||||
*
|
||||
* @see #hasExplicitGlobal()
|
||||
* @see #initGlobal(ContextFactory)
|
||||
*/
|
||||
public static ContextFactory getGlobal()
|
||||
{
|
||||
return global;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if global factory was set.
|
||||
* Return true to indicate that {@link #initGlobal(ContextFactory)} was
|
||||
* already called and false to indicate that the global factory was not
|
||||
* explicitly set.
|
||||
*
|
||||
* @see #getGlobal()
|
||||
* @see #initGlobal(ContextFactory)
|
||||
*/
|
||||
public static boolean hasExplicitGlobal()
|
||||
{
|
||||
return hasCustomGlobal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set global ContextFactory.
|
||||
* The method can only be called once.
|
||||
*
|
||||
* @see #getGlobal()
|
||||
* @see #hasExplicitGlobal()
|
||||
*/
|
||||
public static void initGlobal(ContextFactory factory)
|
||||
{
|
||||
if (factory == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (hasCustomGlobal) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
hasCustomGlobal = true;
|
||||
global = factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new {@link Context} instance to be associated with the current
|
||||
* thread.
|
||||
* This is a callback method used by Rhino to create {@link Context}
|
||||
* instance when it is necessary to associate one with the current
|
||||
* execution thread. <tt>makeContext()</tt> is allowed to call
|
||||
* {@link Context#seal(Object)} on the result to prevent
|
||||
* {@link Context} changes by hostile scripts or applets.
|
||||
*/
|
||||
protected Context makeContext()
|
||||
{
|
||||
return new Context();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of {@link Context#hasFeature(int featureIndex)}.
|
||||
* This can be used to customize {@link Context} without introducing
|
||||
* additional subclasses.
|
||||
*/
|
||||
protected boolean hasFeature(Context cx, int featureIndex)
|
||||
{
|
||||
int version;
|
||||
switch (featureIndex) {
|
||||
case Context.FEATURE_NON_ECMA_GET_YEAR:
|
||||
/*
|
||||
* During the great date rewrite of 1.3, we tried to track the
|
||||
* evolving ECMA standard, which then had a definition of
|
||||
* getYear which always subtracted 1900. Which we
|
||||
* implemented, not realizing that it was incompatible with
|
||||
* the old behavior... now, rather than thrash the behavior
|
||||
* yet again, we've decided to leave it with the - 1900
|
||||
* behavior and point people to the getFullYear method. But
|
||||
* we try to protect existing scripts that have specified a
|
||||
* version...
|
||||
*/
|
||||
version = cx.getLanguageVersion();
|
||||
return (version == Context.VERSION_1_0
|
||||
|| version == Context.VERSION_1_1
|
||||
|| version == Context.VERSION_1_2);
|
||||
|
||||
case Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME:
|
||||
return false;
|
||||
|
||||
case Context.FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER:
|
||||
return false;
|
||||
|
||||
case Context.FEATURE_TO_STRING_AS_SOURCE:
|
||||
version = cx.getLanguageVersion();
|
||||
return version == Context.VERSION_1_2;
|
||||
|
||||
case Context.FEATURE_PARENT_PROTO_PROPERTIES:
|
||||
return true;
|
||||
|
||||
case Context.FEATURE_E4X:
|
||||
version = cx.getLanguageVersion();
|
||||
return (version == Context.VERSION_DEFAULT
|
||||
|| version >= Context.VERSION_1_6);
|
||||
|
||||
case Context.FEATURE_DYNAMIC_SCOPE:
|
||||
return false;
|
||||
|
||||
case Context.FEATURE_STRICT_VARS:
|
||||
return false;
|
||||
|
||||
case Context.FEATURE_STRICT_EVAL:
|
||||
return false;
|
||||
|
||||
case Context.FEATURE_LOCATION_INFORMATION_IN_ERROR:
|
||||
return false;
|
||||
}
|
||||
// It is a bug to call the method with unknown featureIndex
|
||||
throw new IllegalArgumentException(String.valueOf(featureIndex));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create class loader for generated classes.
|
||||
* This method creates an instance of the default implementation
|
||||
* of {@link GeneratedClassLoader}. Rhino uses this interface to load
|
||||
* generated JVM classes when no {@link SecurityController}
|
||||
* is installed.
|
||||
* Application can override the method to provide custom class loading.
|
||||
*/
|
||||
protected GeneratedClassLoader createClassLoader(ClassLoader parent)
|
||||
{
|
||||
return new DefiningClassLoader(parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ClassLoader to use when searching for Java classes.
|
||||
* Unless it was explicitly initialized with
|
||||
* {@link #initApplicationClassLoader(ClassLoader)} the method returns
|
||||
* null to indicate that Thread.getContextClassLoader() should be used.
|
||||
*/
|
||||
public final ClassLoader getApplicationClassLoader()
|
||||
{
|
||||
return applicationClassLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set explicit class loader to use when searching for Java classes.
|
||||
*
|
||||
* @see #getApplicationClassLoader()
|
||||
*/
|
||||
public final void initApplicationClassLoader(ClassLoader loader)
|
||||
{
|
||||
if (loader == null)
|
||||
throw new IllegalArgumentException("loader is null");
|
||||
if (!Kit.testIfCanLoadRhinoClasses(loader))
|
||||
throw new IllegalArgumentException(
|
||||
"Loader can not resolve Rhino classes");
|
||||
|
||||
if (this.applicationClassLoader != null)
|
||||
throw new IllegalStateException(
|
||||
"applicationClassLoader can only be set once");
|
||||
checkNotSealed();
|
||||
|
||||
this.applicationClassLoader = loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute top call to script or function.
|
||||
* When the runtime is about to execute a script or function that will
|
||||
* create the first stack frame with scriptable code, it calls this method
|
||||
* to perform the real call. In this way execution of any script
|
||||
* happens inside this function.
|
||||
*/
|
||||
protected Object doTopCall(Callable callable,
|
||||
Context cx, Scriptable scope,
|
||||
Scriptable thisObj, Object[] args)
|
||||
{
|
||||
return callable.call(cx, scope, thisObj, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of
|
||||
* {@link Context#observeInstructionCount(int instructionCount)}.
|
||||
* This can be used to customize {@link Context} without introducing
|
||||
* additional subclasses.
|
||||
*/
|
||||
protected void observeInstructionCount(Context cx, int instructionCount)
|
||||
{
|
||||
}
|
||||
|
||||
protected void onContextCreated(Context cx)
|
||||
{
|
||||
Object listeners = this.listeners;
|
||||
for (int i = 0; ; ++i) {
|
||||
Listener l = (Listener)Kit.getListener(listeners, i);
|
||||
if (l == null)
|
||||
break;
|
||||
l.contextCreated(cx);
|
||||
}
|
||||
}
|
||||
|
||||
protected void onContextReleased(Context cx)
|
||||
{
|
||||
Object listeners = this.listeners;
|
||||
for (int i = 0; ; ++i) {
|
||||
Listener l = (Listener)Kit.getListener(listeners, i);
|
||||
if (l == null)
|
||||
break;
|
||||
l.contextReleased(cx);
|
||||
}
|
||||
}
|
||||
|
||||
public final void addListener(Listener listener)
|
||||
{
|
||||
checkNotSealed();
|
||||
synchronized (listenersLock) {
|
||||
if (disabledListening) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
listeners = Kit.addListener(listeners, listener);
|
||||
}
|
||||
}
|
||||
|
||||
public final void removeListener(Listener listener)
|
||||
{
|
||||
checkNotSealed();
|
||||
synchronized (listenersLock) {
|
||||
if (disabledListening) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
listeners = Kit.removeListener(listeners, listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The method is used only to imlement
|
||||
* Context.disableStaticContextListening()
|
||||
*/
|
||||
final void disableContextListening()
|
||||
{
|
||||
checkNotSealed();
|
||||
synchronized (listenersLock) {
|
||||
disabledListening = true;
|
||||
listeners = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this is a sealed ContextFactory.
|
||||
* @see #seal()
|
||||
*/
|
||||
public final boolean isSealed()
|
||||
{
|
||||
return sealed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Seal this ContextFactory so any attempt to modify it like to add or
|
||||
* remove its listeners will throw an exception.
|
||||
* @see #isSealed()
|
||||
*/
|
||||
public final void seal()
|
||||
{
|
||||
checkNotSealed();
|
||||
sealed = true;
|
||||
}
|
||||
|
||||
protected final void checkNotSealed()
|
||||
{
|
||||
if (sealed) throw new IllegalStateException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Call {@link ContextAction#run(Context cx)}
|
||||
* using the {@link Context} instance associated with the current thread.
|
||||
* If no Context is associated with the thread, then
|
||||
* {@link #makeContext()} will be called to construct
|
||||
* new Context instance. The instance will be temporary associated
|
||||
* with the thread during call to {@link ContextAction#run(Context)}.
|
||||
*
|
||||
* @see ContextFactory#call(ContextAction)
|
||||
* @see Context#call(ContextFactory factory, Callable callable,
|
||||
* Scriptable scope, Scriptable thisObj,
|
||||
* Object[] args)
|
||||
*/
|
||||
public final Object call(ContextAction action)
|
||||
{
|
||||
return Context.call(this, action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@link Context#enter()} with the difference that if a new context
|
||||
* needs to be created, then this context factory is used to create it
|
||||
* instead of the global context factory.
|
||||
* @return a Context associated with the current thread
|
||||
*/
|
||||
public final Context enter()
|
||||
{
|
||||
return enter(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@link Context#enter(Context)} with the difference that if a new
|
||||
* context needs to be created, then this context factory is used to create
|
||||
* it instead of the global context factory.
|
||||
* @return a Context associated with the current thread
|
||||
*/
|
||||
public final Context enter(Context cx)
|
||||
{
|
||||
return Context.enter(cx, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@link Context#exit()}, although if you used {@link #enter()} or
|
||||
* {@link #enter(Context)} methods on this object, you should use this exit
|
||||
* method instead of the static one in {@link Context}.
|
||||
*/
|
||||
public final void exit()
|
||||
{
|
||||
Context.exit(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,53 +1,60 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Norris Boyd
|
||||
* Norris Boyd
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// API class
|
||||
|
||||
package org.mozilla.javascript;
|
||||
|
||||
/**
|
||||
* Embeddings that wish to
|
||||
* @see org.mozilla.javascript.Context#addContextListener
|
||||
* @deprecated Embeddings that wish to customize newly created
|
||||
* {@link Context} instances should implement
|
||||
* {@link ContextFactory.Listener}.
|
||||
*/
|
||||
public interface ContextListener {
|
||||
|
||||
public void contextCreated(Context cx);
|
||||
public interface ContextListener extends ContextFactory.Listener
|
||||
{
|
||||
|
||||
/**
|
||||
* @deprecated Rhino runtime never calls the method.
|
||||
*/
|
||||
public void contextEntered(Context cx);
|
||||
|
||||
/**
|
||||
* @deprecated Rhino runtime never calls the method.
|
||||
*/
|
||||
public void contextExited(Context cx);
|
||||
|
||||
public void contextReleased(Context cx);
|
||||
}
|
||||
|
||||
@@ -1,38 +1,42 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Waldemar Horwat
|
||||
* Roger Lawrence
|
||||
* Waldemar Horwat
|
||||
* Roger Lawrence
|
||||
* Attila Szegedi
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/****************************************************************
|
||||
*
|
||||
@@ -203,7 +207,7 @@ class DToA {
|
||||
z = d0 & Frac_mask;
|
||||
d0 &= 0x7fffffff; /* clear sign bit, which we ignore */
|
||||
|
||||
if ((de = (int)(d0 >>> Exp_shift)) != 0)
|
||||
if ((de = (d0 >>> Exp_shift)) != 0)
|
||||
z |= Exp_msk1;
|
||||
|
||||
if ((y = d1) != 0) {
|
||||
@@ -301,7 +305,6 @@ class DToA {
|
||||
|
||||
char[] buffer; /* The output string */
|
||||
int p; /* index to current position in the buffer */
|
||||
int q;
|
||||
int digit;
|
||||
double df; /* The fractional part of d */
|
||||
BigInteger b;
|
||||
@@ -553,7 +556,7 @@ class DToA {
|
||||
}
|
||||
|
||||
b = d2b(d, be, bbits);
|
||||
if ((i = (int)(word0(d) >>> Exp_shift1 & (Exp_mask>>Exp_shift1))) != 0) {
|
||||
if ((i = (word0(d) >>> Exp_shift1 & (Exp_mask>>Exp_shift1))) != 0) {
|
||||
d2 = setWord0(d, (word0(d) & Frac_mask1) | Exp_11);
|
||||
/* log(x) ~=~ log(1.5) + (x-1.5)/1.5
|
||||
* log10(x) = log(x) / log(10)
|
||||
@@ -790,8 +793,7 @@ class DToA {
|
||||
}
|
||||
else
|
||||
if (d < 0.5 - eps) {
|
||||
while (buf.charAt(buf.length() - 1) == '0')
|
||||
buf.setLength(buf.length() - 1);
|
||||
stripTrailingZeroes(buf);
|
||||
// while(*--s == '0') ;
|
||||
// s++;
|
||||
return k + 1;
|
||||
@@ -1132,9 +1134,7 @@ class DToA {
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Strip trailing zeros */
|
||||
while (buf.charAt(buf.length() - 1) == '0')
|
||||
buf.setLength(buf.length() - 1);
|
||||
stripTrailingZeroes(buf);
|
||||
// while(*--s == '0') ;
|
||||
// s++;
|
||||
}
|
||||
@@ -1151,6 +1151,16 @@ class DToA {
|
||||
return k + 1;
|
||||
}
|
||||
|
||||
private static void
|
||||
stripTrailingZeroes(StringBuffer buf)
|
||||
{
|
||||
// while(*--s == '0') ;
|
||||
// s++;
|
||||
int bl = buf.length();
|
||||
while(bl-->0 && buf.charAt(bl) == '0');
|
||||
buf.setLength(bl + 1);
|
||||
}
|
||||
|
||||
/* Mapping of JSDToStrMode -> JS_dtoa mode */
|
||||
private static final int dtoaModes[] = {
|
||||
0, /* DTOSTR_STANDARD */
|
||||
@@ -1180,7 +1190,6 @@ class DToA {
|
||||
boolean exponentialNotation = false;
|
||||
int minNDigits = 0; /* Minimum number of significand digits required by mode and precision */
|
||||
int p;
|
||||
int q;
|
||||
|
||||
switch (mode) {
|
||||
case DTOSTR_STANDARD:
|
||||
|
||||
@@ -1,39 +1,42 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mike Ang
|
||||
* Igor Bukanov
|
||||
* Mike McCabe
|
||||
* Mike Ang
|
||||
* Igor Bukanov
|
||||
* Mike McCabe
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
package org.mozilla.javascript;
|
||||
|
||||
@@ -112,14 +115,11 @@ public class Decompiler
|
||||
return sourceTop;
|
||||
}
|
||||
|
||||
int markFunctionStart(int functionType, String name)
|
||||
int markFunctionStart(int functionType)
|
||||
{
|
||||
int savedOffset = getCurrentOffset();
|
||||
addToken(Token.FUNCTION);
|
||||
append((char)functionType);
|
||||
if (name.length() != 0) {
|
||||
addName(name);
|
||||
}
|
||||
return savedOffset;
|
||||
}
|
||||
|
||||
@@ -147,15 +147,6 @@ public class Decompiler
|
||||
append((char)Token.EOL);
|
||||
}
|
||||
|
||||
void addAssignOp(int op)
|
||||
{
|
||||
if (!(0 <= op && op <= Token.LAST_TOKEN))
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
append((char)Token.ASSIGNOP);
|
||||
append((char)op);
|
||||
}
|
||||
|
||||
void addName(String str)
|
||||
{
|
||||
addToken(Token.NAME);
|
||||
@@ -301,11 +292,11 @@ public class Decompiler
|
||||
if (length == 0) { return ""; }
|
||||
|
||||
int indent = properties.getInt(INITIAL_INDENT_PROP, 0);
|
||||
if (indent < 0) Kit.badArg();
|
||||
if (indent < 0) throw new IllegalArgumentException();
|
||||
int indentGap = properties.getInt(INDENT_GAP_PROP, 4);
|
||||
if (indentGap < 0) Kit.badArg();
|
||||
if (indentGap < 0) throw new IllegalArgumentException();
|
||||
int caseGap = properties.getInt(CASE_GAP_PROP, 2);
|
||||
if (caseGap < 0) Kit.badArg();
|
||||
if (caseGap < 0) throw new IllegalArgumentException();
|
||||
|
||||
StringBuffer result = new StringBuffer();
|
||||
boolean justFunctionBody = (0 != (flags & Decompiler.ONLY_BODY_FLAG));
|
||||
@@ -601,62 +592,58 @@ public class Decompiler
|
||||
result.append(" = ");
|
||||
break;
|
||||
|
||||
case Token.ASSIGNOP:
|
||||
++i;
|
||||
switch (source.charAt(i)) {
|
||||
case Token.ADD:
|
||||
result.append(" += ");
|
||||
break;
|
||||
case Token.ASSIGN_ADD:
|
||||
result.append(" += ");
|
||||
break;
|
||||
|
||||
case Token.SUB:
|
||||
result.append(" -= ");
|
||||
break;
|
||||
case Token.ASSIGN_SUB:
|
||||
result.append(" -= ");
|
||||
break;
|
||||
|
||||
case Token.MUL:
|
||||
result.append(" *= ");
|
||||
break;
|
||||
case Token.ASSIGN_MUL:
|
||||
result.append(" *= ");
|
||||
break;
|
||||
|
||||
case Token.DIV:
|
||||
result.append(" /= ");
|
||||
break;
|
||||
case Token.ASSIGN_DIV:
|
||||
result.append(" /= ");
|
||||
break;
|
||||
|
||||
case Token.MOD:
|
||||
result.append(" %= ");
|
||||
break;
|
||||
case Token.ASSIGN_MOD:
|
||||
result.append(" %= ");
|
||||
break;
|
||||
|
||||
case Token.BITOR:
|
||||
result.append(" |= ");
|
||||
break;
|
||||
case Token.ASSIGN_BITOR:
|
||||
result.append(" |= ");
|
||||
break;
|
||||
|
||||
case Token.BITXOR:
|
||||
result.append(" ^= ");
|
||||
break;
|
||||
case Token.ASSIGN_BITXOR:
|
||||
result.append(" ^= ");
|
||||
break;
|
||||
|
||||
case Token.BITAND:
|
||||
result.append(" &= ");
|
||||
break;
|
||||
case Token.ASSIGN_BITAND:
|
||||
result.append(" &= ");
|
||||
break;
|
||||
|
||||
case Token.LSH:
|
||||
result.append(" <<= ");
|
||||
break;
|
||||
case Token.ASSIGN_LSH:
|
||||
result.append(" <<= ");
|
||||
break;
|
||||
|
||||
case Token.RSH:
|
||||
result.append(" >>= ");
|
||||
break;
|
||||
case Token.ASSIGN_RSH:
|
||||
result.append(" >>= ");
|
||||
break;
|
||||
|
||||
case Token.URSH:
|
||||
result.append(" >>>= ");
|
||||
break;
|
||||
}
|
||||
case Token.ASSIGN_URSH:
|
||||
result.append(" >>>= ");
|
||||
break;
|
||||
|
||||
case Token.HOOK:
|
||||
result.append(" ? ");
|
||||
break;
|
||||
|
||||
case Token.OBJLIT:
|
||||
// pun OBJLIT to mean colon in objlit property initialization.
|
||||
// this needs to be distinct from COLON in the general case
|
||||
case Token.OBJECTLIT:
|
||||
// pun OBJECTLIT to mean colon in objlit property
|
||||
// initialization.
|
||||
// This needs to be distinct from COLON in the general case
|
||||
// to distinguish from the colon in a ternary... which needs
|
||||
// different spacing.
|
||||
result.append(':');
|
||||
@@ -791,6 +778,22 @@ public class Decompiler
|
||||
result.append(" % ");
|
||||
break;
|
||||
|
||||
case Token.COLONCOLON:
|
||||
result.append("::");
|
||||
break;
|
||||
|
||||
case Token.DOTDOT:
|
||||
result.append("..");
|
||||
break;
|
||||
|
||||
case Token.DOTQUERY:
|
||||
result.append(".(");
|
||||
break;
|
||||
|
||||
case Token.XMLATTR:
|
||||
result.append('@');
|
||||
break;
|
||||
|
||||
default:
|
||||
// If we don't know how to decompile it, raise an exception.
|
||||
throw new RuntimeException();
|
||||
@@ -862,7 +865,7 @@ public class Decompiler
|
||||
lbits = (long)source.charAt(offset) << 48;
|
||||
lbits |= (long)source.charAt(offset + 1) << 32;
|
||||
lbits |= (long)source.charAt(offset + 2) << 16;
|
||||
lbits |= (long)source.charAt(offset + 3);
|
||||
lbits |= source.charAt(offset + 3);
|
||||
if (type == 'J') {
|
||||
number = lbits;
|
||||
} else {
|
||||
|
||||
@@ -1,37 +1,40 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Norris Boyd
|
||||
* Norris Boyd
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
package org.mozilla.javascript;
|
||||
|
||||
@@ -40,26 +43,60 @@ package org.mozilla.javascript;
|
||||
*
|
||||
* @author Norris Boyd
|
||||
*/
|
||||
class DefaultErrorReporter implements ErrorReporter {
|
||||
class DefaultErrorReporter implements ErrorReporter
|
||||
{
|
||||
static final DefaultErrorReporter instance = new DefaultErrorReporter();
|
||||
|
||||
public void warning(String message, String sourceName, int line,
|
||||
String lineSource, int lineOffset)
|
||||
private boolean forEval;
|
||||
private ErrorReporter chainedReporter;
|
||||
|
||||
private DefaultErrorReporter() { }
|
||||
|
||||
static ErrorReporter forEval(ErrorReporter reporter)
|
||||
{
|
||||
// do nothing
|
||||
DefaultErrorReporter r = new DefaultErrorReporter();
|
||||
r.forEval = true;
|
||||
r.chainedReporter = reporter;
|
||||
return r;
|
||||
}
|
||||
|
||||
public void error(String message, String sourceName, int line,
|
||||
String lineSource, int lineOffset)
|
||||
public void warning(String message, String sourceURI, int line,
|
||||
String lineText, int lineOffset)
|
||||
{
|
||||
throw new EvaluatorException(message, sourceName, line,
|
||||
lineSource, lineOffset);
|
||||
if (chainedReporter != null) {
|
||||
chainedReporter.warning(
|
||||
message, sourceURI, line, lineText, lineOffset);
|
||||
} else {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
public EvaluatorException runtimeError(String message, String sourceName,
|
||||
int line, String lineSource,
|
||||
public void error(String message, String sourceURI, int line,
|
||||
String lineText, int lineOffset)
|
||||
{
|
||||
if (forEval) {
|
||||
throw ScriptRuntime.constructError(
|
||||
"SyntaxError", message, sourceURI, line, lineText, lineOffset);
|
||||
}
|
||||
if (chainedReporter != null) {
|
||||
chainedReporter.error(
|
||||
message, sourceURI, line, lineText, lineOffset);
|
||||
} else {
|
||||
throw runtimeError(
|
||||
message, sourceURI, line, lineText, lineOffset);
|
||||
}
|
||||
}
|
||||
|
||||
public EvaluatorException runtimeError(String message, String sourceURI,
|
||||
int line, String lineText,
|
||||
int lineOffset)
|
||||
{
|
||||
throw new EvaluatorException(message, sourceName, line,
|
||||
lineSource, lineOffset);
|
||||
if (chainedReporter != null) {
|
||||
return chainedReporter.runtimeError(
|
||||
message, sourceURI, line, lineText, lineOffset);
|
||||
} else {
|
||||
return new EvaluatorException(
|
||||
message, sourceURI, line, lineText, lineOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Rhino code, released
|
||||
* May 6, 1999.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1997-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Norris Boyd
|
||||
* Roger Lawrence
|
||||
* Patrick Beard
|
||||
* Igor Bukanov
|
||||
* Norris Boyd
|
||||
* Roger Lawrence
|
||||
* Patrick Beard
|
||||
* Igor Bukanov
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which
|
||||
* case the provisions of the GPL are applicable instead of those above. If
|
||||
* you wish to allow use of your version of this file only under the terms of
|
||||
* the GPL and not to allow others to use your version of this file under the
|
||||
* MPL, indicate your decision by deleting the provisions above and replacing
|
||||
* them with the notice and other provisions required by the GPL. If you do
|
||||
* not delete the provisions above, a recipient may use your version of this
|
||||
* file under either the MPL or the GPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
package org.mozilla.javascript;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* Load generated classes.
|
||||
*
|
||||
@@ -56,7 +56,11 @@ public class DefiningClassLoader extends ClassLoader
|
||||
}
|
||||
|
||||
public Class defineClass(String name, byte[] data) {
|
||||
return super.defineClass(name, data, 0, data.length);
|
||||
// Use our own protection domain for the generated classes.
|
||||
// TODO: we might want to use a separate protection domain for classes
|
||||
// compiled from scripts, based on where the script was loaded from.
|
||||
return super.defineClass(name, data, 0, data.length,
|
||||
SecurityUtilities.getProtectionDomain(getClass()));
|
||||
}
|
||||
|
||||
public void linkClass(Class cl) {
|
||||
@@ -80,5 +84,5 @@ public class DefiningClassLoader extends ClassLoader
|
||||
return cl;
|
||||
}
|
||||
|
||||
private ClassLoader parentLoader;
|
||||
private final ClassLoader parentLoader;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user