Compare commits

..

18 Commits

Author SHA1 Message Date
igor%mir2.org
f2aa6a70ce From http://bugzilla.mozilla.org/show_bug.cgi?id=225831#c22 :
Fix for bug 225831

The patch adds new parse tree node type, Token.RETURN_POPV, to return the value
stored by the last Token.POPV and updates interpreter/optimizer to support POPV
for functions and the new nodes. With this it in place NodeTransformer changes
code to return from finally to first store via POPV the result of the original
return, then execute finally and then return the stored value fixing bug
225831.

The patch does not depend on changes to avoid using temporaries during
expression evaluation as I initially expected but it does depend on the change
to use recursion of NodeTransformer which is committed on the bug branch so log
it here.


git-svn-id: svn://10.0.0.236/branches/templess_bytecode_225831@150025 18797224-902f-48f8-a5cc-f745e15eee43
2003-12-04 11:30:03 +00:00
igor%mir2.org
13af7cdb7a Using recursion in NodeTransformer instead of iterator for greater flexibility of tree work
git-svn-id: svn://10.0.0.236/branches/templess_bytecode_225831@149926 18797224-902f-48f8-a5cc-f745e15eee43
2003-12-02 17:25:01 +00:00
igor%mir2.org
5bb4acf87e Work on bug 225831:
Some preparations to change NodeTransformer to use recursion instead of iteretaor as it would make life simpler to implement fix for bug 226517


git-svn-id: svn://10.0.0.236/branches/templess_bytecode_225831@149925 18797224-902f-48f8-a5cc-f745e15eee43
2003-12-02 15:23:55 +00:00
igor%mir2.org
1192a41e48 From http://bugzilla.mozilla.org/show_bug.cgi?id=225831#c21 :
Check for local overuse

The patch adds checks in Interpreter to throw an exception if number of locals
exceeds 256 and switch to use activation if number of variables exceeds 256. In
this way silent reuse of locals would be avoided and interpreter limitations
are exposed earlier.

Without the the patch js1_5/Regress/regress-226507.js would go to infinite loop
when N there is increased to 257.


git-svn-id: svn://10.0.0.236/branches/templess_bytecode_225831@149874 18797224-902f-48f8-a5cc-f745e15eee43
2003-12-01 18:23:46 +00:00
igor%mir2.org
0a432d2774 From http://bugzilla.mozilla.org/show_bug.cgi?id=225831#c20 :
reuse of locals

To allow reuse of additional locals that interpreter/optimizer has to allocate
to support try/catch/finally and for (in) patch adds new parse node node,
Token.LOCAL_BLOCK to indicate sequence of statements that needs new local. In
this way simple stack-like allocation of local slots in the interpreter
provides locals reuse and in the optimizer the locals can be treated in the
same way as temporaries and does not require initial preallocation.


git-svn-id: svn://10.0.0.236/branches/templess_bytecode_225831@149873 18797224-902f-48f8-a5cc-f745e15eee43
2003-12-01 17:14:41 +00:00
igor%mir2.org
50bda67745 From http://bugzilla.mozilla.org/show_bug.cgi?id=225831#c19 :
using temporaries, not locals, to hold intermediate results in optimizer

The patch changes omj/optimizer/Block.java to use temporaries instead of locals
to hold results of common this subexpressions since in the optimizer
temporaries are reused while locals are not unless special measures are taken.

Since the previous patches changes moved creation of temporaries to static
method in OptTransformer, the change removed the need to pass IRFactory
instance around Block and FatBlock and the patch removes it.


git-svn-id: svn://10.0.0.236/branches/templess_bytecode_225831@149853 18797224-902f-48f8-a5cc-f745e15eee43
2003-11-30 15:38:23 +00:00
igor%mir2.org
bcc5719262 From http://bugzilla.mozilla.org/show_bug.cgi?id=225831#c18 :
templess catch

Currently handling of the catch statement involves creation of 2 locals per
catch block, one to store catch object and another to hold catch scope during
its setup. The second usage should use temporary instead since additional
catch, finally or with blocks can not appear between the initial creation of
scope and creation of with object that uses it. So effectively it is a
temporary and as previous patches shows it could be eliminated.

The patch just does that via changing Token.NEWSCOPE nodes into
Token.CATCH_SCOPE since the former was used only to support catch nodes. The
new node is responsible for populating properly the scope objects based on the
exception thus eliminating the last temporary usage in the Interpreter and
simplifying catch parsing trees substantially.


git-svn-id: svn://10.0.0.236/branches/templess_bytecode_225831@149852 18797224-902f-48f8-a5cc-f745e15eee43
2003-11-30 10:51:53 +00:00
igor%mir2.org
2b8f80b63d Commenting out debug printouts
git-svn-id: svn://10.0.0.236/branches/templess_bytecode_225831@149841 18797224-902f-48f8-a5cc-f745e15eee43
2003-11-29 19:26:52 +00:00
igor%mir2.org
029886bdf6 From http://bugzilla.mozilla.org/show_bug.cgi?id=225831#c17 :
templess enum

Patch adds new parse tree node, Token.ENUM_ID, to get id string from
enumeration object that is used to implement "for (x in y)". In this way code
to generate byte code to store the result of enumNext to compare it with null
and assign to enum counter becomes unnecessary.


git-svn-id: svn://10.0.0.236/branches/templess_bytecode_225831@149840 18797224-902f-48f8-a5cc-f745e15eee43
2003-11-29 19:12:36 +00:00
igor%mir2.org
9a61fc3f3d From http://bugzilla.mozilla.org/show_bug.cgi?id=225831#c16 :
templess calls in interpreter

The patch changes interpreter not to use temporaries to calculate both function
reference and function this for function calls. The patch moved away the code
to transform parsing tree in NodeTrandformer and instead adds necessary logic
to interpreter. The code is moved to the OptTransformer so optimizer still uses
it.
The patch changes few special interpreter byte codes that supported function
this calculations to place on the stack both function reference and its this.
In this way byte code for calls became more compact and faster.

It seems that direct code generation from non-transformed call subtree would
shrink generated byte code in the optimizer as well but since various
optimizations there depends on particular transformed tree structure I left it
as is since the optimizer handles references properly


git-svn-id: svn://10.0.0.236/branches/templess_bytecode_225831@149825 18797224-902f-48f8-a5cc-f745e15eee43
2003-11-28 18:00:59 +00:00
igor%mir2.org
d0a1ae80b5 From http://bugzilla.mozilla.org/show_bug.cgi?id=225831#c15 :
removal of unused Node.cloneNode

The previous patches removes the need to to have Node.cloneNode so the patch
removes it.


git-svn-id: svn://10.0.0.236/branches/templess_bytecode_225831@149676 18797224-902f-48f8-a5cc-f745e15eee43
2003-11-24 14:53:13 +00:00
igor%mir2.org
22e05ce99f From http://bugzilla.mozilla.org/show_bug.cgi?id=225831#c14 :
usings dups for [] and {}

The patch changes code to generate [] and {} to use dups instead of temporaries to get shorter byte code both for interpreter and optimizer. With the patch the test case now passes in the interpreted mode.


git-svn-id: svn://10.0.0.236/branches/templess_bytecode_225831@149675 18797224-902f-48f8-a5cc-f745e15eee43
2003-11-24 12:42:46 +00:00
igor%mir2.org
48713b116f From comments for
http://bugzilla.mozilla.org/show_bug.cgi?id=225831 :

templess op=

The patch changes generation of code for various op= to use dup commands
instead of saving lvalue into temporaries and then restoring it from
temporaries to store assignment result. In this way more compact code is
generated both for interpreter and optimizer and IRFactory code for op= is
simplified since it is no longer necessary to apply optimization of loading
numbers and strings twice instead of using temporaries as DUP is the fastest
way to duplicate even constant values.

The price for this is the need to support 2 additional node types, SETELEM_OP
and SETPROP_OP, but most of the code for them is shared with SETELEM and
SETPROP so the total code bloat is not that big.


git-svn-id: svn://10.0.0.236/branches/templess_bytecode_225831@149657 18797224-902f-48f8-a5cc-f745e15eee43
2003-11-23 19:44:07 +00:00
igor%mir2.org
2cdeb1ce87 Added missed debug string conversion for typeofname
git-svn-id: svn://10.0.0.236/branches/templess_bytecode_225831@149633 18797224-902f-48f8-a5cc-f745e15eee43
2003-11-22 20:51:30 +00:00
igor%mir2.org
a5267aaeff From CVS comments for http://bugzilla.mozilla.org/show_bug.cgi?id=225831 :
templess switch

Another source for stack depth miscalculations is switch code, where stack was
not updated to account for IF jump.  The patch resolves via using 2 new byte
codes, Icode_DUPSECOND duplicating stack element one below top and
Icode_IFEQ_POP which would pop additional stack element in case of successful
jump. In this way switch condition will be popped from the stack when done.

To prevent stack miscalculations, the patch adds explicit checks for expected
stack change during code generation. The overhead of this self checking should
be very low.

The patch also adds one line fix to optimizer/Codegen to release switch
register after code for switches is generated.


git-svn-id: svn://10.0.0.236/branches/templess_bytecode_225831@149632 18797224-902f-48f8-a5cc-f745e15eee43
2003-11-22 20:44:18 +00:00
igor%mir2.org
776c546185 From comments for http://bugzilla.mozilla.org/show_bug.cgi?id=225831:
Different handling of "if" and "?"

One of the reasons of stack miscalculations is that current IRFactory reuse the
code for "if" statement when generation tree for "?". Since then/else parts of
"?" places an object to stack while then/else of "if" suppose to keep stack the
same, so effectively byte code generation end up assuming 2 additional objects
on stack, not one, for each "?".

The problem presents in the optimizer as well, so class files claims more stack
space then necessary there also.

Patch handles that via using Token.HOOK for parse subtree representing "?" and
adding code to interpreter/optimizer to process that properly.

Patch also adds missed stack adjustments for &&, ||, __proto__ and __parent__
in Interpreter.

I will committ the patch to the branch after regression testing.


git-svn-id: svn://10.0.0.236/branches/templess_bytecode_225831@149612 18797224-902f-48f8-a5cc-f745e15eee43
2003-11-21 13:36:01 +00:00
igor%mir2.org
2dc354fa94 From bugzilla comments for http://bugzilla.mozilla.org/show_bug.cgi?id=225831 :
First part: no more temporaries for post ++ and --


This is trivial part since the patch changes IR-Factory to always creates
Token.INC/Token.DEC nodes for post ++ and --. Previously it happens only for
child nodes of ++ or -- where IRFactory.hasSideEffects() returns true but the
rest of code in Rhino both in interpreter and optimizer modes contained full
support for INC/DEC applied for arbitrary complex lvalue expression. Or did I
miss something?


git-svn-id: svn://10.0.0.236/branches/templess_bytecode_225831@149443 18797224-902f-48f8-a5cc-f745e15eee43
2003-11-17 18:38:17 +00:00
(no author)
14d18a9ce7 This commit was manufactured by cvs2svn to create branch
'templess_bytecode_225831'.

git-svn-id: svn://10.0.0.236/branches/templess_bytecode_225831@149442 18797224-902f-48f8-a5cc-f745e15eee43
2003-11-17 18:31:56 +00:00
247 changed files with 37824 additions and 45481 deletions

View File

@@ -1,39 +1,37 @@
<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 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 the Initial Developer are Copyright (C) 1998-1999
- the Initial Developer. All Rights Reserved.
-
-
- 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.
-
- 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 ***** -->
- 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.
-->
<body>
<h1>
<span CLASS=LXRSHORTDESC>

View File

@@ -1,65 +1,22 @@
# ***** 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/ContextAction.java,\
src/org/mozilla/javascript/ContextFactory.java,\
src/org/mozilla/javascript/GeneratedClassLoader.java,\
src/org/mozilla/javascript/ContextListener.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/RefCallable.java,\
src/org/mozilla/javascript/RhinoException.java,\
src/org/mozilla/javascript/PropertyException.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

View File

@@ -1,64 +0,0 @@
# ***** 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_6R5
# See Context#getImplementationVersion() for format of this!
implementation.version: Rhino 1.6 release 5 ${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.1
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

View File

@@ -1,41 +1,5 @@
<?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):
Norris Boyd
Igor Bukanov
David P. Caldwell
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 or later
@@ -44,65 +8,57 @@ Requires Ant version 1.2 or later
<project name="Rhino" default="help" basedir=".">
<target name="properties">
<!-- 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="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"/>
<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="xmlimplsrc-build-file"
location="xmlimplsrc/build.xml"/>
<available property="xmlimplsrc-present?"
file="${xmlimplsrc-build-file}" />
<property name="docsrc.dir" value="docs"/>
<property name="dist.docsrc.dir" value="src/docs"/>
</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 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"/>
<ant dir="src" target="compile"/>
<ant dir="toolsrc" target="compile"/>
</target>
<target name="copy-source" depends="init">
<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"/>
<ant dir="src" target="copy-source"/>
<ant dir="toolsrc" 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="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">
<target name="jar" depends="compile">
<jar jarfile="${dist.dir}/${rhino.jar}"
basedir="${classes}"
manifest="src/manifest"
@@ -115,18 +71,14 @@ 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"/>
@@ -135,13 +87,13 @@ Requires Ant version 1.2 or later
</target>
<target name="copy-examples" depends="init">
<mkdir dir="${dist.dir}/examples"/>
<copy todir="${dist.dir}/examples">
<fileset dir="examples" includes="**/*.java,**/*.js,**/*.html" />
<copy todir="${dist.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=".">
@@ -156,43 +108,36 @@ Requires Ant version 1.2 or later
</target>
<target name="copy-docs" depends="init">
<echo message="copy from docs"/>
<mkdir dir="${dist.dir}/docs"/>
<copy todir="${dist.dir}/docs">
<fileset dir="docs" includes="**/*.html,**/*.jpg,**/*.gif,**/*.js" />
<echo message="copy from ${docsrc.dir}"/>
<copy todir="${dist.docs}">
<fileset dir="${docsrc.dir}"
includes="**/*.html,**/*.jpg,**/*.gif" />
</copy>
</target>
<target name="javadoc" depends="copy-docs">
<mkdir dir="${dist.dir}/docs/apidocs"/>
<target name="javadoc" depends="compile,copy-docs">
<javadoc sourcefiles="${apiClasses}"
sourcepath="src"
destdir="${dist.dir}/docs/apidocs"
overview="${dist.dir}/docs/api.html"
destdir="${dist.apidocs}"
overview="${dist.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 destfile="${dist.file}">
<fileset dir="${build.dir}" includes="${dist.name}/**"/>
</zip>
<zip zipfile="${dist.file}"
basedir="${build.dir}"
includes="**"
excludes="classes/**" />
</target>
<target name="source-zip" depends="copy-source,copy-examples,copy-docs">
<target name="source-zip" depends="copy-source">
<delete file="${dist.source-only-zip}" />
<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>
<zip zipfile="${dist.source-only-zip}" basedir="${build.dir}"
includes="${dist.name}/src/**,${dist.name}/toolsrc/**,${dist.name}/build.xml,${dist.name}/apiClasses.properties"/>
</target>
<target name="clean" depends="properties">
@@ -212,13 +157,8 @@ Requires Ant version 1.2 or later
clean remove all compiled classes and copied 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
compile compile all classes and copy all property files
into ${classes} directory
including deprecated code
deepclean remove all generated files and directories
@@ -232,11 +172,11 @@ Requires Ant version 1.2 or later
minimalist set of Rhino classes. See footprint.html
from the doc directory for details.
javadoc generate Rhino API documentation
in ${dist.dir}/docs/apidocs
javadoc generate generate Rhino API documentation
in ${dist.apidocs}
source-zip create ${dist.source-only-zip} with all Rhino
source files necessary to recreate ${dist.file}
source files necessary to recreate ${rhino.jar}
</echo>
</target>

View File

@@ -1,61 +0,0 @@
<?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>

View File

@@ -1,53 +0,0 @@
/* -*- 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);
}
}

View File

@@ -1,52 +0,0 @@
/* -*- 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() { }
}

View File

@@ -1,54 +0,0 @@
/* -*- 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);
}
}

View File

@@ -1,37 +1,3 @@
<!-- ***** 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">
@@ -53,7 +19,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 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>
</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>
<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-&gt;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

View File

@@ -1,37 +1,3 @@
<!-- ***** 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>
@@ -58,8 +24,9 @@ JavaScript evaluation engine with a Java thread, set attributes of the
engine, and compile and evaluate scripts.</li>
<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>
<a href="org/mozilla/javascript/ContextListener.html">ContextListener</a>
- Allows embeddings to be notified of the creation, entering, exiting,
and releasing of Contexts. </li>
<li>
<a href="org/mozilla/javascript/Script.html">Script</a> - The result of
@@ -86,12 +53,14 @@ by objects wrapping other objects. Provides a method for recovering the
wrapped value.</li>
<li>
<a href="org/mozilla/javascript/WrapFactory.html">WrapFactory</a> - Class
embedders can extend in order to control the way Java objects are wrapped
<a href="org/mozilla/javascript/WrapHandler.html">WrapHandler</a> - Interface
embedders can implement in order to control the way Java objects are wrapped
for use by JavaScript.</li>
<li>
<a href="org/mozilla/javascript/optimizer/ClassCompiler.html">ClassCompiler</a> - Class that provies API for compiling scripts into JVM class files.</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>
<li>
<a href="org/mozilla/javascript/serialize/ScriptableOutputStream.html">ScriptableOutputStream</a> - This stream can be used to serialize JavaScript objects and functions.
@@ -107,7 +76,7 @@ for use by JavaScript.</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.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>.
to script existing Java classes, you should just use <a href="http://developer.netscape.com/library/documentation/communicator/jsguide4/livecon.htm">LiveConnect</a>.
It is also helpful to understand some of the implementation of the <a href="runtime.html">runtime</a>.
<ul>
<li>
@@ -134,7 +103,7 @@ to be used as JavaScript function objects.</li>
<li>
<a href="org/mozilla/javascript/ImporterTopLevel.html">ImporterTopLevel</a>
- Allows embeddings to use the JavaImporter constructor.</li>
- Allows embeddings to use the importClass and importPackage functions.</li>
</ul>
<h4>
@@ -142,23 +111,27 @@ 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. It wrapps the JavaScript value from 'throw' statement.</li>
- Thrown from within JavaScript by the JavaScript 'throw' statement, or
by LiveConnect calls from JavaScript into Java. Wraps a JavaScript value.</li>
<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>
<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>
<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>
<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>
<li>
<a href="org/mozilla/javascript/EvaluatorException.html">EvaluatorException</a>
- An exception thrown when an error is detected during the compilation or execution of
- An exception thrown when an error is detected during the execution of
a script. The default error reporter will throw EvaluatorExceptions when
an error is encountered.</li>
</ul>

View File

@@ -1,78 +1,43 @@
<!-- ***** 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="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>
<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>
</head>
<body>
<body bgcolor="#FFFFFF">
<script src="owner.js"></script>
<h1>Rhino and BSF</h1>
<center>
<h1>
Using Rhino with BSF and Apache</h1></center>
<script>document.write(owner());</script>
<h2>What is BSF?</h2>
<p>
The <a href="http://jakarta.apache.org/bsf/">Bean
<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
Scripting Framework</a> (or BSF) was originally developed by IBM and now
published as open source as a project at the Apache Software Foundation. It provides a framework for using a number of
published as open source. 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/">Xalan</a>
including the XSL processor <a href="http://xml.apache.org/xalan-j/index.html">Xalan</a>
and the XML/Java build tool <a href="http://ant.apache.org/">Ant</a>.
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>If you use BSF 2.3.0 Release candidate 1 (released 2002-11-12) or earlier versions, you have to use Rhino 1.5R2 or Rhino 1.5R3 (see Rhino <a href="download.html">download</a> page).
</p>
<p>
If you want to use later releases of Rhino, then as of time of writing, 2004-11-29, you have to either build BSF from <a href="http://jakarta.apache.org/site/cvsindex.html">Apache's CVS</a> or use pre-built binaries since BSF project has not yet released an official version incorporating all the necessary changes to work with Rhino 1.5R4 or later.
</p>
<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.
<p><a href="index.html">back to top</a>
</body>
</html>

View File

@@ -1,75 +1,21 @@
<!-- ***** 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 name="generator" content=
"HTML Tidy for Cygwin (vers 1st September 2004), see www.w3.org">
<meta http-equiv="Content-Type" content=
"text/html; charset=us-ascii">
<meta name="Author" content="Igor Bukanov">
<meta name="KeyWords" content="Rhino, JavaScript, Java">
<title>Change Log</title>
<style type="text/css">
P { text-align: justify; }
</style>
<!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>
</head>
<body bgcolor="#FFFFFF">
<h1 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>
<hr width="100%">
<br>
<a href="index.html">back to top</a>
</body>
</html>
<body bgcolor="#ffffff">
<h1 align="center">
Change Log for Significant Rhino Changes</h1>
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>

View File

@@ -1,37 +1,3 @@
<!-- ***** 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>

View File

@@ -1,165 +1,171 @@
<!-- ***** 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="KeyWords" content="Rhino, JavaScript, Java">
<title>Rhino Documentation</title>
<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>
</head>
<style>
h1 { text-align: center }
th { text-align: left; font-weight: normal; width: 220px }
hr { width: 100% }
</style>
<body>
<body bgcolor="#ffffff">
<center>
<h1> Rhino Documentation</h1>
<h3>General</h3>
<table>
<tbody>
<tr>
<th><a href="overview.html">Overview</a></th>
<td>An overview of the JavaScript language and of Rhino.</td>
</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>
</tr>
<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>
<td><a href="limits.html">Requirements and Limitations</a>
</td>
<td>What you must have to run Rhino; what Rhino cannot do.</td>
</tr>
<tr>
<th><a href="changes.html">Change log</a></th>
<td>Recent Rhino Changes</td>
<tr>
<td><a href="rhino15R4.html">What's new in 1.5R4</a>
</td>
<td>Changes since 1.5R3.</td>
</tr>
<tr>
<th><a href="opt.html">Optimization</a></th>
<td>Details on the various optimization levels.</td>
<tr>
<td><a href="debugger.html">Rhino Debugger</a>
</td>
<td>A debugger for debugging JavaScript running in Rhino.</td>
</tr>
<tr>
<th><a href="faq.html">FAQ</a></th>
<td>Answers to frequently asked questions about Rhino.</td>
<tr>
<td><a href="opt.html">Optimization</a>
</td>
<td>Details on the various optimization levels.</td>
</tr>
<tr>
<th><a 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>
<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>
</tbody>
<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>
</table>
<h3>Writing Scripts</h3>
<table>
<tbody>
<tr>
<th><a href="ScriptingJava.html">Scripting Java</a></th>
<td>How to use Rhino to script Java classes.</td>
<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>
</tr>
<tr>
<th><a href="scriptjava.html">Scripting Java</a></th>
<td>How to use Rhino to script Java classes (an older treatment).</td>
<tr>
<td><a href="scriptjava.html">Scripting Java</a>
</td>
<td>How to use Rhino to script Java classes (an older treatment).</td>
</tr>
<tr>
<th><a href="perf.html">Performance Hints</a></th>
<td>Some tips on writing faster JavaScript code.</td>
<tr>
<td><a href="perf.html">Performance Hints</a>
</td>
<td>Some tips on writing faster JavaScript code.</td>
</tr>
</tbody>
<tr>
<td><a href="tools.html">Tools</a>
</td>
<td>Some tools for developing JavaScript scripts.</td>
</tr>
</tbody>
</table>
<h3>JavaScript Tools</h3>
<table>
<tbody>
<tr>
<th><a href="shell.html">JavaScript Shell</a></th>
<td>Interactive or batch execution of scripts.</td>
</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>
</tr>
<tr>
<th><a href="debugger.html">JavaScript Debugger</a></th>
<td>Debugging scripts running in Rhino.</td>
<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>
<tr>
<th><a href="jsc.html">JavaScript Compiler</a></th>
<td>Compiling scripts into Java class files.</td>
</tr>
<tr>
<th><a href="http://www.mozilla.org/js/tests/library.html">Testing</a></th>
<td>Running the JavaScript test suite.</td>
</tr>
</tbody>
</table>
<h3>Embedding Rhino</h3>
<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>
<th><a href="apidocs/index.html">API javadoc Reference</a></th>
<td>An annotated outline of the programming interface to Rhino (tip only).</td>
</tr>
<tr>
<th><a href="scopes.html">Scopes and Contexts</a></th>
<td>Describes how to use scopes and contexts for the best performance
<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>
<tr>
<th><a href="serialization.html">Serialization</a></th>
<td>How to serialize JavaScript objects and functions in Rhino.</td>
<tr>
<td><a href="serialization.html">Serialization</a>
</td>
<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>
<td><a href="runtime.html">Runtime</a>
</td>
<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>
<td><a href="footprint.html">Small Footprint</a>
</td>
<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
<tr>
<td><a href="examples.html">Examples</a>
</td>
<td>A set of examples showing how to control the JavaScript engine and
build JavaScript host objects.</td>
</tr>
<tr>
<th><a href="bsf.html">Using Rhino with BSF</a></th>
<td>How to use Rhino with apps that support BSF (Bean Scripting Framework) from the Apache Jakarta project.</td>
<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>
</tbody>
</tbody>
</table>
<h3><hr><a href="index.html">back to top</a></h3>
</p>
<h3>
<hr width="100%"><a href="index.html">back to top</a>
</h3>
</body>
</html>

View File

@@ -1,37 +1,3 @@
<!-- ***** 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>
@@ -44,135 +10,81 @@
<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>
<p>
You can download binary distributions of Rhino from <a
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>
. These zip files includes precompiled <tt>js.jar</tt> with all Rhino classes, documentation, examples and sources.
</p>
<p>
Rhino 1.6R5 is the last qualified release. It includes support for <a
href="http://www.ecma-international.org/publications/standards/Ecma-357.htm">ECMAScript for XML</a> (E4X). To implement E4X runtime Rhino uses <a
href="http://xmlbeans.apache.org/">XMLBeans</a> library and if you would like to use E4X you need to add <tt>xbean.jar</tt> from XMLBeans distribution to your class path.</p>
<table border=1 cellpadding=2 cellspacing=0>
<thead>
<tr>
<th>Release</th>
<th>Release Date</th>
<th>Change log</th>
<th>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>
. 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), 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>
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/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://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
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&nbsp; <a
href="http://www.mozilla.org/cvs.html">source code via cvs</a> for
details on how to set up CVS, define your CVSROOT, and login. Once
you've done that, just execute the command
<pre>&nbsp;&nbsp;&nbsp; cvs co mozilla/js/rhino</pre>
to get the tip source.
<p>The current tip can also be viewed using LXR at <a
href="http://lxr.mozilla.org/mozilla/source/js/rhino/">
http://lxr.mozilla.org/mozilla/source/js/rhino/</a> . See also <a href="changes.html">change log</a> for the current tip.</p>
<p>
Rhino uses <a href="http://ant.apache.org/">Ant</a> as its build system and running <tt>ant</tt> command at the top directory of Rhino distribution should print the list of available build targets.
</p>
http://lxr.mozilla.org/mozilla/source/js/rhino/</a> . </p>
<p> </p>
<hr width="100%"><a href="index.html">back to top</a> <br>
&nbsp; <br>
</body>

View File

@@ -1,37 +1,3 @@
<!-- ***** 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>
@@ -86,7 +52,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="./)">www.mozilla.org/rhino)</a>,
<p><font face="Arial"><font size=-1>The scripting engine Rhino (<a href="http://www.mozilla.org/js)">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>
@@ -195,7 +161,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/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/js/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>
@@ -217,7 +183,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/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/js/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>
@@ -300,8 +266,8 @@ file - " + args[0]);</font></font>
<br>&nbsp;
<br>&nbsp;
<p><font face="Arial"><font size=-1>For more explanations on the code execution,
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>
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>
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;

View File

@@ -1,37 +1,3 @@
<!-- ***** 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>
@@ -102,7 +68,7 @@ by only performing that expensive operation once.
<br>&nbsp;
<h2>
Implementing Host Objects</h2>
First check out the <a href="tutorial.html">tutorial</a>
First check out the <a href="http://www.mozilla.org/rhino/tutorial.html">tutorial</a>
if you haven't already.
<h4>
The Foo class - Extending ScriptableObject</h4>

View File

@@ -1,37 +1,3 @@
<!-- ***** 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>

View File

@@ -1,37 +1,3 @@
<!-- ***** 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>
@@ -56,8 +22,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
code for classfile generation that include all the classes from
<tt>org.mozilla.javascript.optimizer</tt> package.
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.
<h3>JavaAdapter</h3>
<p>
@@ -79,19 +45,13 @@ 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>
<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:
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:
<pre>
ant clean
ant -Ddebug=off -Dno-regexp=true -Dno-e4x=true smalljar
ant -Ddebug=off -Dno-regexp=true smalljar
</pre>
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.
If you omit <tt>-Dno-regexp=true</tt>, then the resulting smalljs.jar will include Regular Expression support.
<p>
<hr WIDTH="100%">

View File

@@ -1,82 +1,41 @@
<!-- ***** 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">
<title>Help with Rhino</title>
<script src="owner.js"></script>
<style>
h1 { text-align: center }
</style>
<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>
</head>
<body>
<h1>Help with Rhino</h1>
<center><b><font size=+3>Help with Rhino</font></b></center>
<script src="owner.js"></script>
<p>Have a question that you can't find answer to in the <a href="doc.html">documentation</a>?
Here are some additional resources for help:
</p>
<h3>Newsgroup and Mail Gateway</h3>
<p>
<br>&nbsp;
<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>
<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.
</p>
<h3>Bug System</h3>
<p>
<h3>
Bug System</h3>
Use <a href="http://bugzilla.mozilla.org/enter_bug.cgi?product=Rhino">Bugzilla</a>
to enter bugs against Rhino. Note that Rhino has its own product category.
</p>
<h3>Module Owner</h3>
<p>
The module owner,&nbsp;<script>document.write(owner());</script>, can
<br>&nbsp;
<h3>
Module Owner</h3>
The module owner,&nbsp;<script>document.write(owner());</script>
, can
be mailed for help as well, although he may copy his response to the newsgroup
to help others.
</p>
<p>
<hr WIDTH="100%"><a href="index.html">back to top</a>
<br>&nbsp;

View File

@@ -1,66 +1,75 @@
<!-- ***** 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">
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title>Rhino - JavaScript for Java</title>
<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>
</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&nbsp;</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>

View File

@@ -1,37 +1,3 @@
<!-- ***** 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>
@@ -67,7 +33,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="apidocs/org/mozilla/javascript/SecuritySupport.html">SecuritySupport</a>
I've implemented an addition to the <a href="../js/rhino/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>
@@ -76,7 +42,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="apidocs/org/mozilla/javascript/ImporterTopLevel.html">ImporterTopLevel</a>
<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>
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.

View File

@@ -1,37 +1,3 @@
<!-- ***** 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>
@@ -93,7 +59,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>,
<tt>140</tt>, <tt>150</tt>, or <tt>160</tt>. See <a href="overview.html#versions">JavaScript Language
or <tt>140</tt>. See <a href="overview.html#versions">JavaScript Language
Versions</a> for more information on language versions.</ul>
<h2>

View File

@@ -1,37 +1,3 @@
<!-- ***** 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>
@@ -115,6 +81,6 @@ Earlier versions may return:
<p>The Microsoft SDK 3.1 for Java also exhibits this problem.
<p>
<hr WIDTH="100%">
<br><a href="#">back to top</a>
<br><a href="rhino.html">back to top</a>
</body>
</html>

View File

@@ -1,37 +1,3 @@
<!-- ***** 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=iso-8859-1">

View File

@@ -1,37 +1,3 @@
<!-- ***** 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>
@@ -73,10 +39,8 @@ Language</h3>
The JavaScript language itself is standardized by Standard ECMA-262 <i>ECMAScript:
A general purpose, cross-platform programming language</i>. Rhino 1.5 implements
JavaScript 1.5, which conforms to Edition 3 of the Standard. The Standard
may be <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">downloaded</a> or
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&ocirc;ne, CH1204 Geneva, Switzerland.
<p>Rhino 1.6 also implements ECMA-357 <i>ECMAScript for XML (E4X)</i>. See the <a href="http://www.ecma-international.org/publications/standards/Ecma-357.htm">specification</a> for more information on the standard, and <a href="rhino16R1.html#E4X">Rhino version 1.6R1</a> for details on the implementation in Rhino.
<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.

View File

@@ -1,49 +1,3 @@
/* ***** 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 owner() {
return '<a href="mailto:nboyd'+'@'+ 'atg.com">Norris Boyd</a>'
}
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));
}

View File

@@ -1,37 +1,3 @@
<!-- ***** 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>

View File

@@ -1,37 +1,3 @@
<!-- ***** 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>
@@ -114,7 +80,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="jsc.html">http://www.mozilla.org/rhino/jsc.html</a>.
protocols like applets and servlets. See <a href="http://www.mozilla.org/rhino/jsc.html">http://www.mozilla.org/rhino/jsc.html</a>.
<br>&nbsp;
<h3>
LiveConnect 3</h3>
@@ -136,7 +102,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="apidocs/org/mozilla/javascript/ScriptableObject.html#defineClass(org.mozilla.javascript.Scriptable, java.lang.Class)">javadoc</a>
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>
for details.
<br>&nbsp;
<h3>
@@ -153,7 +119,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="apidocs/org/mozilla/javascript/SecuritySupport.html">SecuritySupport</a>
and I've implemented an addition to the <a href="../js/rhino/org/mozilla/javascript/SecuritySupport.html">SecuritySupport</a>
interface that allows embedders to choose which classes are exposed to
scripts.
<br>&nbsp;
@@ -161,7 +127,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="apidocs/org/mozilla/javascript/SecuritySupport.html">SecuritySupport</a>
class files). It didn't support the <a href="../js/rhino/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
@@ -174,14 +140,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="apidocs/org/mozilla/javascript/Context.html#exit()">javadoc</a>
the <a href="http://www.mozilla.org/js/rhino/org/mozilla/javascript/Context.html#exit()">javadoc</a>
for more information on its operation.
<br>&nbsp;
<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="apidocs/org/mozilla/javascript/Context.html#enter(org.mozilla.javascript.Context)">javadoc</a>
See the <a href="http://www.mozilla.org/js/rhino/org/mozilla/javascript/Context.html#enter(org.mozilla.javascript.Context)">javadoc</a>
for more information on its operation.
<br>&nbsp;
<h3>

View File

@@ -1,37 +1,3 @@
<!-- ***** 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>

View File

@@ -1,37 +1,3 @@
<!-- ***** 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>

View File

@@ -1,37 +1,3 @@
<!-- ***** 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">

View File

@@ -1,37 +1,3 @@
<!-- ***** 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">

View File

@@ -1,37 +1,3 @@
<!-- ***** 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>

View File

@@ -1,197 +0,0 @@
<!-- ***** 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)))&nbsp;==&nbsp;uneval(x)</tt> and in many cases more useful notion <tt>eval(uneval(x))&nbsp;==&nbsp;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&gt; var x = { a: 1, b: 2, c: [1,2,3,4,5], f: function test() { return 1; }, o: { property1: "Test", proeprty2: new Date()}}
js&gt; 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&gt; 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&gt; 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&amp;target_milestone=1.5R5&amp;bug_status=RESOLVED&amp;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>

View File

@@ -1,187 +0,0 @@
<!-- ***** 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>

View File

@@ -1,442 +0,0 @@
<!-- ***** 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&amp;short_desc_type=allwordssubstr&amp;short_desc=&amp;product=Rhino&amp;long_desc_type=substring&amp;long_desc=&amp;bug_file_loc_type=allwordssubstr&amp;bug_file_loc=&amp;status_whiteboard_type=allwordssubstr&amp;status_whiteboard=&amp;keywords_type=allwords&amp;keywords=&amp;resolution=FIXED&amp;emailassigned_to1=1&amp;emailtype1=exact&amp;email1=&amp;emailassigned_to2=1&amp;emailreporter2=1&amp;emailqa_contact2=1&amp;emailtype2=exact&amp;email2=&amp;bugidtype=include&amp;bug_id=&amp;votes=&amp;chfieldfrom=2004-11-29&amp;chfieldto=2005-08-21&amp;chfield=resolution&amp;chfieldvalue=FIXED&amp;cmdtype=doit&amp;order=Reuse+same+sort+as+last+time&amp;field0-0-0=noop&amp;type0-0-0=noop&amp;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" =&gt; 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>&nbsp;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>

View File

@@ -1,103 +0,0 @@
<!-- ***** 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>

View File

@@ -1,37 +1,3 @@
<!-- ***** 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>
@@ -131,7 +97,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="apidocs/org/mozilla/javascript/Scriptable.html">Scriptable</a>
<p>Instead, every property accessor method in <a href="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
@@ -147,14 +113,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="apidocs/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="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="apidocs/org/mozilla/javascript/ScriptableObject.html">ScriptableObject</a>
<a href="org/mozilla/javascript/ScriptableObject.html">ScriptableObject</a>
and
<a href="apidocs/org/mozilla/javascript/FunctionObject.html">FunctionObject</a>,
<a href="org/mozilla/javascript/FunctionObject.html">FunctionObject</a>,
such as <tt>defineProperty</tt> and <tt>defineFunctionProperties</tt>.
<br>&nbsp;
<br>&nbsp;

View File

@@ -1,37 +1,3 @@
<!-- ***** 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>
@@ -192,8 +158,9 @@ 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.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
<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
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">

View File

@@ -1,37 +1,3 @@
<!-- ***** 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>
@@ -42,12 +8,21 @@
<title>Scripting Java</title>
</head>
<body bgcolor="#FFFFFF">
<script src="owner.js"></script>
<center>
<h1>
Scripting Java</h1>
<p>Norris Boyd</p>
</center>
Scripting Java</h1></center>
<script>document.write(owner());</script>
<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>
<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
@@ -104,7 +79,7 @@ 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.currentContext
js> cx = Packages.org.mozilla.javascript.Context.enter()
org.mozilla.javascript.Context@25980b44
js> cx.evaluateString(this, "3+2", null, 0, null)
5.0
@@ -193,7 +168,7 @@ 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 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 <tt>printDate</tt> directly to <tt>addActionListener</tt> and simplifies example:
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")

View File

@@ -1,37 +1,3 @@
<!-- ***** 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>

View File

@@ -1,37 +1,3 @@
<!-- ***** 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,40 +18,21 @@ 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>
<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>
<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>
<tt>-version <i>versionNumber</i></tt>
<blockquote>
Specifies the language version to compile with. The string <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
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>
Versions</a> for more information on language versions.</ul>
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
@@ -153,10 +100,6 @@ 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>
@@ -282,26 +225,9 @@ 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>

View File

@@ -0,0 +1,31 @@
<!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>&nbsp;
<br>&nbsp;
<br>&nbsp;
<h2>
JavaScript compiler</h2>
The <a href="jsc.html">JavaScript compiler</a> translates JavaScript source
into Java class files.
<br>&nbsp;
<p>
<hr WIDTH="100%">
<br><a href="index.html">back to top</a>
</body>
</html>

View File

@@ -1,37 +1,3 @@
<!-- ***** 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>
@@ -244,8 +210,9 @@ 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">Object wrappedOut = Context.javaToJS(System.out, scope);</font></tt>
<br><tt><font color="#006600">ScriptableObject.putProperty(scope, "out", wrappedOut);</font></tt></dir>
<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>
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>

View File

@@ -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&nbsp;<script>document.write(owner());</script>.
Rhino--just mail&nbsp;<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,11 +29,6 @@ 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
@@ -44,55 +39,22 @@ 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 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.
<br>ICEsoft Technologies adds JavaScript support to their <a href="http://www.icesoft.com/ps_browser_overview.html">ICEbrowser</a> using Rhino.
<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.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.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
@@ -101,12 +63,6 @@ into any workstep of their application," said Dr. Kelvin Liu, VP eBMS Developmen
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.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>.

View File

@@ -1,39 +1,36 @@
/* -*- 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 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, 1998.
*
* 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.
* 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 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 ***** */
* 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.
*/
import org.mozilla.javascript.*;
@@ -53,47 +50,55 @@ 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 {
// 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']}",
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]));
} finally {
Context.exit();
} catch (JavaScriptException e) {
// ignore
}
cx.exit();
}
}

View File

@@ -1,40 +1,37 @@
/* -*- 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 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, 1998.
*
* 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.
* 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.
*
* Contributor(s):
* Norris Boyd
* 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 ***** */
* 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.
*/
import org.mozilla.javascript.*;

View File

@@ -1,40 +1,37 @@
/* -*- 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 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, 1998.
*
* 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.
* 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.
*
* Contributor(s):
* Norris Boyd
* 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 ***** */
* 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.
*/
import org.mozilla.javascript.*;

View File

@@ -1,40 +1,37 @@
/* -*- 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 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, 1998.
*
* 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.
* 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):
* Norris Boyd
* 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 ***** */
* 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.
*/
import org.mozilla.javascript.*;
@@ -43,94 +40,65 @@ 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 to run functions with and
* relative to that shared scope. Try compiling 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 {
// 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);
cx.setCompileFunctionsWithDynamicScope(false);
runScripts(cx);
cx.setCompileFunctionsWithDynamicScope(true);
runScripts(cx);
} finally {
cx.exit();
}
}
static void runScripts(Context cx, Script script)
static void runScripts(Context cx)
throws JavaScriptException
{
// 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 sharedScope = cx.initStandardObjects(null, true);
ScriptableObject scope = cx.initStandardObjects(null, true);
// 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 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 spawn some threads that execute a script that calls the
// function 'f'. The scope chain looks like this:
// <pre>
// ------------------ ------------------
// | per-thread scope | -prototype-> | shared scope |
// ------------------ ------------------
// ------------------
// | shared scope |
// ------------------
// ^
// |
// parentScope
// ------------------
// | per-thread scope |
// ------------------
// ^
// |
// ------------------
// | f's activation |
@@ -144,13 +112,9 @@ public class DynamicScopes {
final int threadCount = 3;
Thread[] t = new Thread[threadCount];
for (int i=0; i < threadCount; i++) {
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,
String script = "function g() { var x = 'local'; return f(); }" +
"java.lang.System.out.println(g());";
t[i] = new Thread(new PerThread(scope, script,
"thread" + i));
}
for (int i=0; i < threadCount; i++)
@@ -167,9 +131,9 @@ public class DynamicScopes {
static class PerThread implements Runnable {
PerThread(Scriptable sharedScope, String source, String x) {
this.sharedScope = sharedScope;
this.source = source;
PerThread(Scriptable scope, String script, String x) {
this.scope = scope;
this.script = script;
this.x = x;
}
@@ -178,8 +142,8 @@ public class DynamicScopes {
Context cx = Context.enter();
try {
// We can share the scope.
Scriptable threadScope = cx.newObject(sharedScope);
threadScope.setPrototype(sharedScope);
Scriptable threadScope = cx.newObject(scope);
threadScope.setPrototype(scope);
// We want "threadScope" to be a new top-level
// scope, so set its parent scope to null. This
@@ -190,13 +154,17 @@ 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, source, "threadScript", 1, null);
} finally {
cx.evaluateString(threadScope, script, "threadScript", 1, null);
}
catch (JavaScriptException jse) {
// ignore
}
finally {
Context.exit();
}
}
private Scriptable sharedScope;
private String source;
private Scriptable scope;
private String script;
private String x;
}

View File

@@ -1,223 +0,0 @@
/* -*- 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("----------------------------------------");

View File

@@ -1,40 +1,37 @@
/* -*- 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 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, 1998.
*
* 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.
* 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):
* Norris Boyd
* 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 ***** */
* 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.
*/
import org.mozilla.javascript.*;
import java.io.*;
@@ -131,9 +128,11 @@ 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
throws IOException, JavaScriptException
{
Vector v = new Vector();
String s;
@@ -253,7 +252,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.javaToJS(reader, parent);
return Context.toObject(reader, parent);
}
/**
@@ -266,7 +265,7 @@ public class File extends ScriptableObject {
if (writer == null)
return null;
Scriptable parent = ScriptableObject.getTopLevelScope(this);
return Context.javaToJS(writer, parent);
return Context.toObject(writer, parent);
}
/**

View File

@@ -1,39 +1,36 @@
/* -*- 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 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, 1998.
*
* 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.
* 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 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 ***** */
* 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.
*/
import org.mozilla.javascript.*;

View File

@@ -1,39 +1,36 @@
/* -*- 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 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, 1998.
*
* 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.
* 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 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 ***** */
* 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.
*/
import org.mozilla.javascript.*;
import java.util.Vector;

View File

@@ -1,37 +1,3 @@
<!-- ***** 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:

View File

@@ -1,37 +1,3 @@
/* ***** 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
/*

View File

@@ -1,40 +1,37 @@
/* -*- 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 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, 1998.
*
* 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.
* 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
* 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 ***** */
* 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.
*/
import org.mozilla.javascript.*;

View File

@@ -1,39 +1,36 @@
/* -*- 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 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, 1998.
*
* 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.
* 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.
*
* 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 ***** */
* 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.
*/
import org.mozilla.javascript.*;
@@ -47,6 +44,7 @@ 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.

View File

@@ -1,39 +1,36 @@
/* -*- 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 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, 1998.
*
* 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.
* 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.
*
* 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 ***** */
* 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.
*/
import org.mozilla.javascript.*;
@@ -44,6 +41,7 @@ import org.mozilla.javascript.*;
*/
public class RunScript2 {
public static void main(String args[])
throws JavaScriptException
{
Context cx = Context.enter();
try {
@@ -51,8 +49,8 @@ public class RunScript2 {
// Add a global variable "out" that is a JavaScript reflection
// of System.out
Object jsOut = Context.javaToJS(System.out, scope);
ScriptableObject.putProperty(scope, "out", jsOut);
Scriptable jsArgs = Context.toObject(System.out, scope);
scope.put("out", scope, jsArgs);
String s = "";
for (int i=0; i < args.length; i++) {

View File

@@ -1,39 +1,36 @@
/* -*- 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 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, 1998.
*
* 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.
* 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.
*
* 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 ***** */
* 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.
*/
import org.mozilla.javascript.*;
@@ -47,6 +44,7 @@ import org.mozilla.javascript.*;
*/
public class RunScript3 {
public static void main(String args[])
throws JavaScriptException
{
Context cx = Context.enter();
try {

View File

@@ -1,39 +1,36 @@
/* -*- 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 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, 1998.
*
* 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.
* 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.
*
* 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 ***** */
* 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.
*/
import org.mozilla.javascript.*;

View File

@@ -1,39 +1,36 @@
/* -*- 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 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, 1998.
*
* 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.
* 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 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 ***** */
* 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.
*/
import org.mozilla.javascript.*;
import java.io.*;
@@ -73,8 +70,12 @@ 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" };
shell.defineFunctionProperties(names, Shell.class,
ScriptableObject.DONTENUM);
try {
shell.defineFunctionProperties(names, Shell.class,
ScriptableObject.DONTENUM);
} catch (PropertyException e) {
throw new Error(e.getMessage());
}
args = processOptions(cx, args);

View File

@@ -1,37 +1,3 @@
/* ***** 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.
@@ -39,73 +5,57 @@
* @author Roger E Critchlow, Jr.
*/
var swingNames = JavaImporter();
importPackage(Packages.javax.swing);
importPackage(Packages.java.awt);
importPackage(Packages.java.awt.event);
swingNames.importPackage(Packages.javax.swing);
swingNames.importPackage(Packages.java.awt);
swingNames.importPackage(Packages.java.awt.event);
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);
/*
* 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;
}
}
with (swingNames) {
try {
UIManager.
setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
} catch (e) { }
//Create the top-level container and add contents to it.
var frame = new swingNames.JFrame("SwingApplication");
frame.getContentPane().add(createComponents(), BorderLayout.CENTER);
// 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);
}
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);
//Finish setting up the frame, and show it.
frame.pack();
frame.setVisible(true);
/*
* 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) { }
//Create the top-level container and add contents to it.
var frame = new 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);

View File

@@ -1,40 +1,37 @@
/* -*- 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 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 the Initial Developer are Copyright (C) 1997-1999
* the Initial Developer. All Rights Reserved.
* 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
* 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 ***** */
* 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.
*/
/**
* checkParam.js

View File

@@ -1,68 +1,69 @@
/* -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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/
* 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.
* 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.
* 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):
* Patrick Beard
* Patrick Beard
*
* 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 ***** */
* 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.
*/
/*
Implementing the interface java.util.Enumeration passing the object
with JavaScript implementation directly to the constructor.
This is a shorthand for JavaAdapter constructor:
enum.js
elements = new JavaAdapter(java.util.Enumeration, {
index: 0,
elements: array,
hasMoreElements: function ...
nextElement: function ...
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 ...
});
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())

View File

@@ -1,41 +1,38 @@
/* -*- 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 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 the Initial Developer are Copyright (C) 1997-1999
* the Initial Developer. All Rights Reserved.
* 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
* Roland Pennings
* Norris Boyd
* Roland Pennings
*
* 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 ***** */
* 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.
*/
/**
* Process a JavaScript source file and process special comments
@@ -130,7 +127,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 separate file with the function table of contents
// so we can have a seperate 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
@@ -157,7 +154,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 separate file with the function table of contents
// so we can have a seperate 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

View File

@@ -1,40 +1,37 @@
/* -*- 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 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 the Initial Developer are Copyright (C) 1997-1999
* the Initial Developer. All Rights Reserved.
* 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
* 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 ***** */
* 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.
*/
/**
* liveConnect.js: a simple demonstration of JavaScript-to-Java connectivity

View File

@@ -1,40 +1,37 @@
/* -*- 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 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 the Initial Developer are Copyright (C) 1997-1999
* the Initial Developer. All Rights Reserved.
* 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
* 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 ***** */
* 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.
*/
// unique.js: read the contents of a file and print out the unique lines

View File

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

View File

@@ -1 +0,0 @@
org.mozilla.javascript.jdkscript.RhinoScriptEngineFactory

View File

@@ -1,78 +1,39 @@
<?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):
Norris Boyd
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 ***** -->
<!--
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">
<javac srcdir="src"
destdir="${classes}"
<target name="compile" depends="properties">
<javac srcdir="."
destdir="${nest}/${classes}"
includes="org/**/*.java"
deprecation="on"
debug="${debug}"
target="${target-jvm}"
source="${source-level}"
>
debug="${debug}">
</javac>
<copy todir="${classes}">
<fileset dir="src" includes="org/**/*.properties" />
<filterset>
<filter token="IMPLEMENTATION.VERSION"
value="${implementation.version}"/>
</filterset>
<copy todir="${nest}/${classes}">
<fileset dir="." includes="org/**/*.properties" />
</copy>
</target>
<target name="copy-source">
<mkdir dir="${dist.dir}/src"/>
<copy todir="${dist.dir}/src">
<fileset dir="src"
includes="**/*.java,**/*.properties,**/*.xml,manifest"/>
<target name="copy-source" depends="properties">
<copy todir="${nest}/${dist.src}">
<fileset dir="."
includes="org/**/*.java,org/**/*.properties,build.xml,manifest"/>
</copy>
</target>
<target name="clean">
<target name="clean" depends="properties">
<delete includeEmptyDirs="true">
<fileset dir="${classes}"
<fileset dir="${nest}/${classes}"
excludes="org/mozilla/javascript/tools/**"/>
</delete>
</target>

View File

@@ -1,3 +1,2 @@
Manifest-Version: 1.0
Main-Class: org.mozilla.javascript.tools.shell.Main
Class-Path: xbean.jar

View File

@@ -1,40 +1,37 @@
/* -*- 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 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 the Initial Developer are Copyright (C) 1997-1999
* the Initial Developer. All Rights Reserved.
* 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):
* Roger Lawrence
* Roger Lawrence
*
* 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 ***** */
* 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;
@@ -50,7 +47,7 @@ public class ByteCode {
/**
* The byte opcodes defined by the Java Virtual Machine.
*/
public static final int
public static final byte
NOP = 0x00,
ACONST_NULL = 0x01,
ICONST_M1 = 0x02,
@@ -179,83 +176,83 @@ public class ByteCode {
LUSHR = 0x7D,
IAND = 0x7E,
LAND = 0x7F,
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,
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,
IMPDEP1 = 0xFE,
IMPDEP2 = 0xFF;
IMPDEP1 = (byte)0xFE,
IMPDEP2 = (byte)0xFF;
/**
* Types for the NEWARRAY opcode.

View File

@@ -1,48 +1,47 @@
/* -*- 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 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 the Initial Developer are Copyright (C) 1997-1999
* the Initial Developer. All Rights Reserved.
* 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):
* Roger Lawrence
* Roger Lawrence
*
* 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 ***** */
* 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;
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
@@ -236,28 +235,6 @@ 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.
*
@@ -288,11 +265,11 @@ public class ClassFileWriter {
* @param vars the array of the variables for the method,
* or null if none
*/
public void stopMethod(short maxLocals) {
public void stopMethod(short maxLocals, JavaVariable[] vars) {
if (itsCurrentMethod == null)
throw new IllegalStateException("No method to stop");
fixLabelGotos();
itsLabels.fixLabelGotos(itsCodeBuffer);
itsMaxLocals = maxLocals;
@@ -305,11 +282,11 @@ public class ClassFileWriter {
}
int variableTableLength = 0;
if (itsVarDescriptors != null) {
if (vars != null) {
// 6 bytes for the attribute header
// 2 bytes for the variable count
// 10 bytes for each entry
variableTableLength = 6 + 2 + (itsVarDescriptors.size() * 10);
variableTableLength = 6 + 2 + (vars.length * 10);
}
int attrLength = 2 + // attribute_name_index
@@ -324,7 +301,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);
@@ -341,19 +318,10 @@ public class ClassFileWriter {
if (itsExceptionTableTop > 0) {
index = putInt16(itsExceptionTableTop, codeAttribute, index);
for (int i = 0; i < itsExceptionTableTop; i++) {
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");
short startPC = itsExceptionTable[i].getStartPC(itsLabels);
short endPC = itsExceptionTable[i].getEndPC(itsLabels);
short handlerPC = itsExceptionTable[i].getHandlerPC(itsLabels);
short catchType = itsExceptionTable[i].getCatchType();
index = putInt16(startPC, codeAttribute, index);
index = putInt16(endPC, codeAttribute, index);
index = putInt16(handlerPC, codeAttribute, index);
@@ -368,7 +336,7 @@ public class ClassFileWriter {
int attributeCount = 0;
if (itsLineNumberTable != null)
attributeCount++;
if (itsVarDescriptors != null)
if (vars != null)
attributeCount++;
index = putInt16(attributeCount, codeAttribute, index);
@@ -384,27 +352,32 @@ public class ClassFileWriter {
}
}
if (itsVarDescriptors != null) {
if (vars != null) {
int variableTableAttrIndex
= itsConstantPool.addUtf8("LocalVariableTable");
index = putInt16(variableTableAttrIndex, codeAttribute, index);
int varCount = itsVarDescriptors.size();
int varCount = vars.length;
int tableAttrLength = 2 + (varCount * 10);
index = putInt32(tableAttrLength, codeAttribute, index);
index = putInt16(varCount, codeAttribute, index);
for (int i = 0; i < varCount; 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;
JavaVariable lvar = vars[i];
index = putInt16(startPC, codeAttribute, index);
int startPc = lvar.getStartPC();
index = putInt16(startPc, codeAttribute, index);
int length = itsCodeBufferTop - startPc;
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);
index = putInt16(register, codeAttribute, index);
int jreg = lvar.getJRegister();
index = putInt16(jreg, codeAttribute, index);
}
}
@@ -417,9 +390,7 @@ public class ClassFileWriter {
itsCurrentMethod = null;
itsMaxStack = 0;
itsStackTop = 0;
itsLabelTableTop = 0;
itsFixupTableTop = 0;
itsVarDescriptors = null;
itsLabels.clearLabels();
}
/**
@@ -427,7 +398,7 @@ public class ClassFileWriter {
*
* @param theOpCode the opcode of the bytecode
*/
public void add(int theOpCode) {
public void add(byte theOpCode) {
if (opcodeCount(theOpCode) != 0)
throw new IllegalArgumentException("Unexpected operands");
int newStack = itsStackTop + stackChange(theOpCode);
@@ -449,7 +420,7 @@ public class ClassFileWriter {
* @param theOpCode the opcode of the bytecode
* @param theOperand the operand of the bytecode
*/
public void add(int theOpCode, int theOperand) {
public void add(byte theOpCode, int theOperand) {
if (DEBUGCODE) {
System.out.println("Add "+bytecodeStr(theOpCode)
+", "+Integer.toHexString(theOperand));
@@ -489,9 +460,9 @@ public class ClassFileWriter {
addToCodeInt16(theOperand);
}
else { // a label
int targetPC = getLabelPC(theOperand);
int theLabel = theOperand & 0x7FFFFFFF;
int targetPC = itsLabels.getLabelPC(theLabel);
if (DEBUGLABELS) {
int theLabel = theOperand & 0x7FFFFFFF;
System.out.println("Fixing branch to " +
theLabel + " at " + targetPC +
" from " + branchPC);
@@ -501,7 +472,7 @@ public class ClassFileWriter {
addToCodeInt16(offset);
}
else {
addLabelFixup(theOperand, branchPC + 1);
itsLabels.addLabelFixup(theLabel, branchPC + 1);
addToCodeInt16(0);
}
}
@@ -526,7 +497,7 @@ public class ClassFileWriter {
if (!(0 <= theOperand && theOperand < 256))
throw new IllegalArgumentException("out of range index");
addToCodeBuffer(theOpCode);
addToCodeBuffer(theOperand);
addToCodeBuffer((byte)theOperand);
break;
case ByteCode.GETFIELD :
@@ -554,7 +525,7 @@ public class ClassFileWriter {
addToCodeInt16(theOperand);
} else {
addToCodeBuffer(theOpCode);
addToCodeBuffer(theOperand);
addToCodeBuffer((byte)theOperand);
}
break;
@@ -578,7 +549,7 @@ public class ClassFileWriter {
}
else {
addToCodeBuffer(theOpCode);
addToCodeBuffer(theOperand);
addToCodeBuffer((byte)theOperand);
}
break;
@@ -647,7 +618,7 @@ public class ClassFileWriter {
* @param theOperand1 the first operand of the bytecode
* @param theOperand2 the second operand of the bytecode
*/
public void add(int theOpCode, int theOperand1, int theOperand2) {
public void add(byte theOpCode, int theOperand1, int theOperand2) {
if (DEBUGCODE) {
System.out.println("Add "+bytecodeStr(theOpCode)
+", "+Integer.toHexString(theOperand1)
@@ -671,8 +642,8 @@ public class ClassFileWriter {
else {
addToCodeBuffer(ByteCode.WIDE);
addToCodeBuffer(ByteCode.IINC);
addToCodeBuffer(theOperand1);
addToCodeBuffer(theOperand2);
addToCodeBuffer((byte)theOperand1);
addToCodeBuffer((byte)theOperand2);
}
}
else if (theOpCode == ByteCode.MULTIANEWARRAY) {
@@ -683,7 +654,7 @@ public class ClassFileWriter {
addToCodeBuffer(ByteCode.MULTIANEWARRAY);
addToCodeInt16(theOperand1);
addToCodeBuffer(theOperand2);
addToCodeBuffer((byte)theOperand2);
}
else {
throw new IllegalArgumentException(
@@ -698,7 +669,7 @@ public class ClassFileWriter {
}
public void add(int theOpCode, String className) {
public void add(byte theOpCode, String className) {
if (DEBUGCODE) {
System.out.println("Add "+bytecodeStr(theOpCode)
+", "+className);
@@ -729,7 +700,7 @@ public class ClassFileWriter {
}
public void add(int theOpCode, String className, String fieldName,
public void add(byte theOpCode, String className, String fieldName,
String fieldType)
{
if (DEBUGCODE) {
@@ -767,7 +738,16 @@ public class ClassFileWriter {
}
}
public void addInvoke(int theOpCode, String className, String methodName,
/**
* @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,
String methodType)
{
if (DEBUGCODE) {
@@ -795,8 +775,8 @@ public class ClassFileWriter {
className, methodName,
methodType);
addToCodeInt16(ifMethodRefIndex);
addToCodeBuffer(parameterCount + 1);
addToCodeBuffer(0);
addToCodeBuffer((byte)(parameterCount + 1));
addToCodeBuffer((byte)0);
}
else {
short methodRefIndex = itsConstantPool.addMethodRef(
@@ -841,11 +821,6 @@ 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.
*
@@ -1047,20 +1022,20 @@ public class ClassFileWriter {
add(ByteCode.ALOAD_0);
}
private void xop(int shortOp, int op, int local)
private void xop(byte shortOp, byte op, int local)
{
switch (local) {
case 0:
add(shortOp);
break;
case 1:
add(shortOp + 1);
add((byte)(shortOp + 1));
break;
case 2:
add(shortOp + 2);
add((byte)(shortOp + 2));
break;
case 3:
add(shortOp + 3);
add((byte)(shortOp + 3));
break;
default:
add(op, local);
@@ -1084,7 +1059,7 @@ public class ClassFileWriter {
int N = addReservedCodeSpace(1 + padSize + 4 * (1 + 2 + entryCount));
int switchStart = N;
itsCodeBuffer[N++] = (byte)ByteCode.TABLESWITCH;
itsCodeBuffer[N++] = ByteCode.TABLESWITCH;
while (padSize != 0) {
itsCodeBuffer[N++] = 0;
--padSize;
@@ -1145,7 +1120,7 @@ public class ClassFileWriter {
switchStart+" is outside a possible range of tableswitch"
+" in already generated code");
}
if ((0xFF & itsCodeBuffer[switchStart]) != ByteCode.TABLESWITCH) {
if (!(itsCodeBuffer[switchStart] == ByteCode.TABLESWITCH)) {
throw new IllegalArgumentException(
switchStart+" is not offset of tableswitch statement");
}
@@ -1159,43 +1134,23 @@ public class ClassFileWriter {
putInt32(jumpTarget - switchStart, itsCodeBuffer, caseOffset);
}
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 int acquireLabel() {
return itsLabels.acquireLabel() | 0x80000000;
}
public void markLabel(int label)
{
if (!(label < 0))
public void markLabel(int label) {
if ((label & 0x80000000) != 0x80000000)
throw new IllegalArgumentException("Bad label, no biscuit");
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;
itsLabels.markLabel(label & 0x7FFFFFFF, itsCodeBufferTop);
}
public void markLabel(int label, short stackTop)
{
markLabel(label);
public void markLabel(int label, short stackTop) {
if ((label & 0x80000000) != 0x80000000)
throw new IllegalArgumentException("Bad label, no biscuit");
itsStackTop = stackTop;
itsLabels.markLabel(label & 0x7FFFFFFF, itsCodeBufferTop);
}
public void markHandler(int theLabel) {
@@ -1203,61 +1158,6 @@ 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.
*
@@ -1282,10 +1182,10 @@ public class ClassFileWriter {
}
}
private void addToCodeBuffer(int b)
private void addToCodeBuffer(byte b)
{
int N = addReservedCodeSpace(1);
itsCodeBuffer[N] = (byte)b;
itsCodeBuffer[N] = b;
}
private void addToCodeInt16(int value)
@@ -2285,7 +2185,7 @@ public class ClassFileWriter {
throw new IllegalArgumentException("Bad opcode: "+opcode);
}
*/
private static String bytecodeStr(int code)
private static String bytecodeStr(byte code)
{
if (DEBUGSTACK || DEBUGCODE) {
switch (code) {
@@ -2527,7 +2427,7 @@ 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;
@@ -2549,15 +2449,7 @@ public class ClassFileWriter {
private short itsSuperClassIndex;
private short itsSourceFileNameIndex;
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 LabelTable itsLabels = new LabelTable();
private char[] tmpCharBuffer = new char[64];
}
@@ -2574,10 +2466,39 @@ final class ExceptionTableEntry
itsCatchType = catchType;
}
int itsStartLabel;
int itsEndLabel;
int itsHandlerLabel;
short itsCatchType;
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;
}
final class ClassFileField

View File

@@ -0,0 +1,66 @@
/*
* 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();
}

View File

@@ -1,41 +1,38 @@
/* -*- 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 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 the Initial Developer are Copyright (C) 1997-1999
* the Initial Developer. All Rights Reserved.
* 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
* Igor Bukanov
* Norris Boyd
* 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 ***** */
* 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;
@@ -47,41 +44,35 @@ package org.mozilla.javascript;
* @see org.mozilla.javascript.NativeCall
* @author Norris Boyd
*/
final class Arguments extends IdScriptableObject
{
static final long serialVersionUID = 4275508002492040609L;
class Arguments extends IdScriptable {
public Arguments(NativeCall activation)
{
public Arguments(NativeCall activation) {
this.activation = activation;
Scriptable parent = activation.getParentScope();
setParentScope(parent);
setPrototype(ScriptableObject.getObjectPrototype(parent));
args = activation.originalArgs;
args = activation.getOriginalArguments();
lengthObj = new Integer(args.length);
NativeFunction f = activation.function;
calleeObj = f;
NativeFunction funObj = activation.funObj;
calleeObj = funObj;
int version = f.getLanguageVersion();
if (version <= Context.VERSION_1_3
&& version != Context.VERSION_DEFAULT)
if (funObj.version <= Context.VERSION_1_3
&& funObj.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;
@@ -90,14 +81,12 @@ final class Arguments extends IdScriptableObject
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)) {
NativeFunction f = activation.function;
String argName = f.getParamOrVarName(index);
String argName = activation.funObj.argNames[index];
value = activation.get(argName, activation);
if (value == NOT_FOUND) Kit.codeBug();
}
@@ -107,17 +96,16 @@ final class Arguments extends IdScriptableObject
return super.get(index, start);
}
private boolean sharedWithActivation(int index)
{
NativeFunction f = activation.function;
int definedCount = f.getParamCount();
private boolean sharedWithActivation(int index) {
NativeFunction f = activation.funObj;
int definedCount = f.argCount;
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.getParamOrVarName(index);
String argName = f.argNames[index];
for (int i = index + 1; i < definedCount; i++) {
if (argName.equals(f.getParamOrVarName(i))) {
if (argName.equals(f.argNames[i])) {
return false;
}
}
@@ -127,19 +115,17 @@ final class Arguments extends IdScriptableObject
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;
argName = activation.function.getParamOrVarName(index);
String argName = activation.funObj.argNames[index];
activation.put(argName, activation, value);
return;
}
synchronized (this) {
if (args[index] != NOT_FOUND) {
if (args == activation.originalArgs) {
if (args == activation.getOriginalArguments()) {
args = (Object[])args.clone();
}
args[index] = value;
@@ -151,12 +137,11 @@ final class Arguments extends IdScriptableObject
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.originalArgs) {
if (args == activation.getOriginalArguments()) {
args = (Object[])args.clone();
}
args[index] = NOT_FOUND;
@@ -167,6 +152,81 @@ final class Arguments extends IdScriptableObject
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
@@ -176,12 +236,9 @@ final class Arguments extends IdScriptableObject
MAX_INSTANCE_ID = 3;
protected int getMaxInstanceId()
{
return MAX_INSTANCE_ID;
}
{ setMaxId(MAX_INSTANCE_ID); }
protected int findInstanceIdInfo(String s)
protected int mapNameToId(String s)
{
int id;
// #generated# Last update: 2002-04-09 20:46:33 CEST
@@ -195,104 +252,11 @@ final class Arguments extends IdScriptableObject
if (X!=null && X!=s && !X.equals(s)) id = 0;
}
// #/generated#
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);
return 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);
} else {
value = null;
}
}
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.

View File

@@ -1,43 +1,40 @@
/* -*- 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 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 the Initial Developer are Copyright (C) 1997-1999
* the Initial Developer. All Rights Reserved.
* 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
* 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 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 ***** */
* 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;
@@ -46,27 +43,23 @@ package org.mozilla.javascript;
* See ECMA 15.3.
* @author Norris Boyd
*/
public class BaseFunction extends IdScriptableObject implements Function
{
public class BaseFunction extends IdScriptable implements Function {
static final long serialVersionUID = 5311394446546053859L;
private static final Object FUNCTION_TAG = new Object();
static void init(Scriptable scope, boolean sealed)
{
static void init(Context cx, Scriptable scope, boolean sealed) {
BaseFunction obj = new BaseFunction();
obj.prototypeFlag = true;
obj.functionName = "";
obj.isPrototypePropertyImmune = true;
obj.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed);
obj.addAsPrototype(MAX_PROTOTYPE_ID, cx, scope, sealed);
}
public BaseFunction()
protected void fillConstructorProperties
(Context cx, IdFunction ctor, boolean sealed)
{
}
public BaseFunction(Scriptable scope, Scriptable prototype)
{
super(scope, prototype);
// Fix up bootstrapping problem: getPrototype of the IdFunction
// can not return Function.prototype because Function object is not
// yet defined.
ctor.setPrototype(this);
}
public String getClassName() {
@@ -90,184 +83,132 @@ public class BaseFunction extends IdScriptableObject implements Function
public boolean hasInstance(Scriptable instance)
{
Object protoProp = ScriptableObject.getProperty(this, "prototype");
if (protoProp instanceof Scriptable) {
if (protoProp instanceof Scriptable && protoProp != Undefined.instance)
{
return ScriptRuntime.jsDelegatesTo(instance, (Scriptable)protoProp);
}
throw ScriptRuntime.typeError1("msg.instanceof.bad.prototype",
getFunctionName());
functionName);
}
// #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()
protected String toSource(Context cx, Scriptable scope, Object[] args)
{
return MAX_INSTANCE_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;
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;
}
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)
? DONTENUM | READONLY | PERMANENT
: DONTENUM;
break;
case Id_arguments:
attr = DONTENUM | PERMANENT;
break;
default: throw new IllegalStateException();
}
return instanceIdInfo(attr, id);
return decompile(cx, indent, flags);
}
protected String getInstanceIdName(int id)
protected int getIdAttributes(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";
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;
}
return super.getInstanceIdName(id);
return super.getIdAttributes(id);
}
protected Object getInstanceIdValue(int id)
{
switch (id) {
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.getInstanceIdValue(id);
}
protected void setInstanceIdValue(int id, Object value)
protected boolean hasIdValue(int id)
{
if (id == Id_prototype) {
if (!isPrototypePropertyImmune) {
prototypeProperty = (value != null)
? value : UniqueTag.NULL_VALUE;
}
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)
{
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();
}
return super.getIdValue(id);
}
protected void setIdValue(int id, Object value)
{
if (id == Id_prototype) {
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();
}
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;
}
defaultPut("arguments", value);
}
super.setInstanceIdValue(id, value);
return super.methodArity(methodId);
}
protected void fillConstructorProperties(IdFunctionObject ctor)
public Object execMethod(int methodId, IdFunction f, Context cx,
Scriptable scope, Scriptable thisObj,
Object[] args)
throws JavaScriptException
{
// 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);
}
if (prototypeFlag) {
switch (methodId) {
case Id_constructor:
return jsConstructor(cx, scope, args);
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;
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);
}
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);
}
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());
return super.execMethod(methodId, f, cx, scope, thisObj, args);
}
/**
@@ -276,9 +217,6 @@ public class BaseFunction extends IdScriptableObject implements Function
*/
public void setImmunePrototypeProperty(Object value)
{
if (isPrototypePropertyImmune) {
throw new IllegalStateException();
}
prototypeProperty = (value != null) ? value : UniqueTag.NULL_VALUE;
isPrototypePropertyImmune = true;
}
@@ -286,7 +224,7 @@ public class BaseFunction extends IdScriptableObject implements Function
protected Scriptable getClassPrototype()
{
Object protoVal = getPrototypeProperty();
if (protoVal instanceof Scriptable) {
if (protoVal instanceof Scriptable && protoVal != Undefined.instance) {
return (Scriptable) protoVal;
}
return getClassPrototype(this, "Object");
@@ -297,26 +235,28 @@ public class BaseFunction extends IdScriptableObject 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) {
if (val instanceof Scriptable && val != Undefined.instance) {
result = (Scriptable)val;
}
} else {
Object val = call(cx, scope, null, args);
if (!(val instanceof Scriptable)) {
if (!(val instanceof Scriptable && val != Undefined.instance)) {
// 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="
+getFunctionName()+" in "+getClass().getName());
+functionName+" in "+getClass().getName());
}
result = (Scriptable)val;
if (result.getPrototype() == null) {
@@ -354,11 +294,13 @@ public class BaseFunction extends IdScriptableObject 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.
*/
String decompile(int indent, int flags)
public String decompile(Context cx, int indent, int flags)
{
StringBuffer sb = new StringBuffer();
boolean justbody = (0 != (flags & Decompiler.ONLY_BODY_FLAG));
@@ -380,12 +322,13 @@ public class BaseFunction extends IdScriptableObject implements Function
public int getLength() { return 0; }
public String getFunctionName()
{
return "";
public String getFunctionName() {
if (functionName == null)
return "";
return functionName;
}
final Object getPrototypeProperty() {
private Object getPrototypeProperty() {
Object result = prototypeProperty;
if (result == null) {
synchronized (this) {
@@ -403,7 +346,9 @@ public class BaseFunction extends IdScriptableObject implements Function
private void setupDefaultPrototype()
{
NativeObject obj = new NativeObject();
final int attr = ScriptableObject.DONTENUM;
final int attr = ScriptableObject.DONTENUM |
ScriptableObject.READONLY |
ScriptableObject.PERMANENT;
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
@@ -418,23 +363,24 @@ public class BaseFunction extends IdScriptableObject 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
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);
// <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;
}
private static Object jsConstructor(Context cx, Scriptable scope,
@@ -478,33 +424,140 @@ public class BaseFunction extends IdScriptableObject implements Function
linep[0] = 1;
}
String sourceURI = ScriptRuntime.
String sourceName = ScriptRuntime.
makeUrlForGeneratedScript(false, filename, linep[0]);
Scriptable global = ScriptableObject.getTopLevelScope(scope);
ErrorReporter reporter;
reporter = DefaultErrorReporter.forEval(cx.getErrorReporter());
// Compile with explicit interpreter instance to force interpreter
// Compile the function with opt level of -1 to force interpreter
// mode.
return cx.compileFunction(global, source, new Interpreter(), reporter,
sourceURI, 1, null);
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;
}
protected int findPrototypeId(String s)
/**
* 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)
{
int id;
// #string_id_map#
// #generated# Last update: 2004-03-17 13:23:22 CET
// #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;
L: switch (s.length()) {
case 4: X="call";id=Id_call; break L;
case 5: X="apply";id=Id_apply; 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 8: 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;
@@ -514,17 +567,19 @@ public class BaseFunction extends IdScriptableObject implements Function
}
private static final int
Id_constructor = 1,
Id_toString = 2,
Id_toSource = 3,
Id_apply = 4,
Id_call = 5,
Id_constructor = MAX_INSTANCE_ID + 1,
Id_toString = MAX_INSTANCE_ID + 2,
Id_apply = MAX_INSTANCE_ID + 3,
Id_call = MAX_INSTANCE_ID + 4,
MAX_PROTOTYPE_ID = 5;
MAX_PROTOTYPE_ID = MAX_INSTANCE_ID + 4;
// #/string_id_map#
protected String functionName;
private Object prototypeProperty;
private boolean isPrototypePropertyImmune;
private boolean prototypeFlag;
}

View File

@@ -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
/* -*- 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
*
* 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,26 +13,27 @@
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
* The Original Code is interface specifiing callable object to execute script
* related code on demand.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1997-1999
* RUnit Software AS.
* Portions created by the Initial Developer are Copyright (C) 2003
* 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
* 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.
* 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.
*
* ***** END LICENSE BLOCK ***** */
@@ -52,8 +53,11 @@ 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);
Object[] args)
throws JavaScriptException;
}

View File

@@ -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
/* -*- 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
*
* 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,31 +13,32 @@
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
* The Original Code is cache holder of generated code for Java reflection
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1997-1999
* RUnit Software AS.
* Portions created by the Initial Developer are Copyright (C) 2003
* 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
* 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.
* 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.
*
* ***** END LICENSE BLOCK ***** */
package org.mozilla.javascript;
import java.io.*;
import java.util.Hashtable;
/**
@@ -56,11 +57,12 @@ public class ClassCache
Hashtable classTable = new Hashtable();
boolean invokerOptimization = true;
Invoker invokerMaster;
Hashtable javaAdapterGeneratedClasses = new Hashtable();
ScriptableObject scope;
private Hashtable interfaceAdapterCache;
Hashtable javaAdapterIFGlueMasters = new Hashtable();
private int generatedClassSerial;
@@ -79,13 +81,21 @@ public class ClassCache
*/
public static ClassCache get(Scriptable scope)
{
ClassCache cache;
cache = (ClassCache)ScriptableObject.getTopScopeValue(scope, AKEY);
if (cache == null) {
// XXX warn somehow about wrong cache usage ?
cache = new ClassCache();
}
return cache;
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();
}
/**
@@ -105,11 +115,7 @@ public class ClassCache
// Can only associate cache with top level scope
throw new IllegalArgumentException();
}
if(this == topScope.associateValue(AKEY, this)) {
scope = topScope;
return true;
}
return false;
return this != topScope.associateValue(AKEY, this);
}
/**
@@ -119,7 +125,11 @@ public class ClassCache
{
classTable = new Hashtable();
javaAdapterGeneratedClasses = new Hashtable();
interfaceAdapterCache = null;
javaAdapterIFGlueMasters = new Hashtable();
Invoker im = invokerMaster;
if (im != null) {
im.clearMasterCaches();
}
}
/**
@@ -134,8 +144,8 @@ public class ClassCache
/**
* Set whether to cache some values.
* <p>
* By default, the engine will cache the results of
* <tt>Class.getMethods()</tt> and similar calls.
* By default, the engine will cache generated classes and
* 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.
@@ -145,7 +155,7 @@ public class ClassCache
* <p>
* Caching is enabled by default.
*
* @param enabled if true, caching is enabled
* @param cachingEnabled if true, caching is enabled
*
* @see #clearCaches()
*/
@@ -159,26 +169,23 @@ public class ClassCache
}
/**
* @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.
* 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.
*/
public synchronized void setInvokerOptimizationEnabled(boolean enabled)
{
if (invokerOptimization == enabled)
return;
if (!enabled)
invokerMaster = null;
invokerOptimization = enabled;
}
/**
@@ -189,26 +196,4 @@ 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);
}
}
}

View File

@@ -0,0 +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/
*
* 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);
}
}

View File

@@ -0,0 +1,142 @@
/* -*- 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;
}

View File

@@ -0,0 +1,55 @@
/* -*- 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;
}

View File

@@ -1,41 +1,38 @@
/* -*- 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 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 the Initial Developer are Copyright (C) 1997-1999
* the Initial Developer. All Rights Reserved.
* 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
* Igor Bukanov
* Norris Boyd
* 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 ***** */
* 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

View File

@@ -1,187 +0,0 @@
/* -*- 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

View File

@@ -1,59 +0,0 @@
/* -*- 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);
}

View File

@@ -1,485 +0,0 @@
/* -*- 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_PROPRTIES}:
* 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_PROPRTIES:
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;
}
// 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);
}
}

View File

@@ -1,60 +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 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 the Initial Developer are Copyright (C) 1997-2000
* the Initial Developer. All Rights Reserved.
* 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):
* Norris Boyd
* 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 ***** */
* 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;
/**
* @deprecated Embeddings that wish to customize newly created
* {@link Context} instances should implement
* {@link ContextFactory.Listener}.
* Embeddings that wish to
* @see org.mozilla.javascript.Context#addContextListener
*/
public interface ContextListener extends ContextFactory.Listener
{
public interface ContextListener {
public void contextCreated(Context cx);
/**
* @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);
}

View File

@@ -1,42 +1,38 @@
/* -*- 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 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 the Initial Developer are Copyright (C) 1997-1999
* the Initial Developer. All Rights Reserved.
* 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):
* Waldemar Horwat
* Roger Lawrence
* Attila Szegedi
* Waldemar Horwat
* Roger Lawrence
*
* 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 ***** */
* 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.
*/
/****************************************************************
*
@@ -794,7 +790,8 @@ class DToA {
}
else
if (d < 0.5 - eps) {
stripTrailingZeroes(buf);
while (buf.charAt(buf.length() - 1) == '0')
buf.setLength(buf.length() - 1);
// while(*--s == '0') ;
// s++;
return k + 1;
@@ -1135,7 +1132,9 @@ class DToA {
}
}
else {
stripTrailingZeroes(buf);
/* Strip trailing zeros */
while (buf.charAt(buf.length() - 1) == '0')
buf.setLength(buf.length() - 1);
// while(*--s == '0') ;
// s++;
}
@@ -1152,16 +1151,6 @@ 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 */

View File

@@ -1,42 +1,39 @@
/* -*- 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 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 the Initial Developer are Copyright (C) 1997-1999
* the Initial Developer. All Rights Reserved.
* 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):
* 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 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 ***** */
* 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;
@@ -115,11 +112,14 @@ public class Decompiler
return sourceTop;
}
int markFunctionStart(int functionType)
int markFunctionStart(int functionType, String name)
{
int savedOffset = getCurrentOffset();
addToken(Token.FUNCTION);
append((char)functionType);
if (name.length() != 0) {
addName(name);
}
return savedOffset;
}
@@ -147,6 +147,15 @@ 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);
@@ -292,11 +301,11 @@ public class Decompiler
if (length == 0) { return ""; }
int indent = properties.getInt(INITIAL_INDENT_PROP, 0);
if (indent < 0) throw new IllegalArgumentException();
if (indent < 0) Kit.badArg();
int indentGap = properties.getInt(INDENT_GAP_PROP, 4);
if (indentGap < 0) throw new IllegalArgumentException();
if (indentGap < 0) Kit.badArg();
int caseGap = properties.getInt(CASE_GAP_PROP, 2);
if (caseGap < 0) throw new IllegalArgumentException();
if (caseGap < 0) Kit.badArg();
StringBuffer result = new StringBuffer();
boolean justFunctionBody = (0 != (flags & Decompiler.ONLY_BODY_FLAG));
@@ -592,58 +601,62 @@ public class Decompiler
result.append(" = ");
break;
case Token.ASSIGN_ADD:
result.append(" += ");
break;
case Token.ASSIGNOP:
++i;
switch (source.charAt(i)) {
case Token.ADD:
result.append(" += ");
break;
case Token.ASSIGN_SUB:
result.append(" -= ");
break;
case Token.SUB:
result.append(" -= ");
break;
case Token.ASSIGN_MUL:
result.append(" *= ");
break;
case Token.MUL:
result.append(" *= ");
break;
case Token.ASSIGN_DIV:
result.append(" /= ");
break;
case Token.DIV:
result.append(" /= ");
break;
case Token.ASSIGN_MOD:
result.append(" %= ");
break;
case Token.MOD:
result.append(" %= ");
break;
case Token.ASSIGN_BITOR:
result.append(" |= ");
break;
case Token.BITOR:
result.append(" |= ");
break;
case Token.ASSIGN_BITXOR:
result.append(" ^= ");
break;
case Token.BITXOR:
result.append(" ^= ");
break;
case Token.ASSIGN_BITAND:
result.append(" &= ");
break;
case Token.BITAND:
result.append(" &= ");
break;
case Token.ASSIGN_LSH:
result.append(" <<= ");
break;
case Token.LSH:
result.append(" <<= ");
break;
case Token.ASSIGN_RSH:
result.append(" >>= ");
break;
case Token.RSH:
result.append(" >>= ");
break;
case Token.ASSIGN_URSH:
result.append(" >>>= ");
case Token.URSH:
result.append(" >>>= ");
break;
}
break;
case Token.HOOK:
result.append(" ? ");
break;
case Token.OBJECTLIT:
// pun OBJECTLIT to mean colon in objlit property
// initialization.
// This needs to be distinct from COLON in the general case
case Token.OBJLIT:
// pun OBJLIT 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(':');
@@ -778,22 +791,6 @@ 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();

View File

@@ -1,40 +1,37 @@
/* -*- 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 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 the Initial Developer are Copyright (C) 1997-1999
* the Initial Developer. All Rights Reserved.
* 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
* 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 ***** */
* 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;
@@ -43,60 +40,26 @@ package org.mozilla.javascript;
*
* @author Norris Boyd
*/
class DefaultErrorReporter implements ErrorReporter
{
static final DefaultErrorReporter instance = new DefaultErrorReporter();
class DefaultErrorReporter implements ErrorReporter {
private boolean forEval;
private ErrorReporter chainedReporter;
private DefaultErrorReporter() { }
static ErrorReporter forEval(ErrorReporter reporter)
public void warning(String message, String sourceName, int line,
String lineSource, int lineOffset)
{
DefaultErrorReporter r = new DefaultErrorReporter();
r.forEval = true;
r.chainedReporter = reporter;
return r;
// do nothing
}
public void warning(String message, String sourceURI, int line,
String lineText, int lineOffset)
public void error(String message, String sourceName, int line,
String lineSource, int lineOffset)
{
if (chainedReporter != null) {
chainedReporter.warning(
message, sourceURI, line, lineText, lineOffset);
} else {
// Do nothing
}
throw new EvaluatorException(message, sourceName, line,
lineSource, lineOffset);
}
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,
public EvaluatorException runtimeError(String message, String sourceName,
int line, String lineSource,
int lineOffset)
{
if (chainedReporter != null) {
return chainedReporter.runtimeError(
message, sourceURI, line, lineText, lineOffset);
} else {
return new EvaluatorException(
message, sourceURI, line, lineText, lineOffset);
}
throw new EvaluatorException(message, sourceName, line,
lineSource, lineOffset);
}
}

View File

@@ -1,44 +1,44 @@
/* ***** 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 the Initial Developer are Copyright (C) 1997-1999
* the Initial Developer. All Rights Reserved.
* 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
* 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 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 ***** */
* 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.lang.reflect.Method;
/**
* Load generated classes.
*

Some files were not shown because too many files have changed in this diff Show More