This was due to a bug where code deviated from the section 3.3.6.1 of the LC3 specification. This commit makes the code compliant with the referenced spec section.
1. Now shell can take compile script. This based on the initial patch from
Patrick Beard <pcbeard@mac.com>.
2. Using common code to read source and compiled scripts and for script
execution.
1. It includes jdk13 package to make the jar usable.
2. It excludes e4x classes as they are useless without xbean.jar and xbean
is several times bigger then the whole js.jar.
New interface RefCallable simplifies implementation of function-call-as-rvalue
in Java code. In addition native objects is required to implemet only Callable
interface, not Function, to serve as target of () operator.
2. Context.getApplicationClassLoader() now uses ContextFactory.getApplicationClassLoader() and also tries ContextFactory subclass as the last resort of loader guessing.
> I work in a group that re-packages the Rhino Debugger as part of a set
> of "C"/JavaScript-based configuration tools for developing embedded
> software. We have had a long-standing problem with setting
> breakOnException, breakOnEnter, and breakOnReturn flags within the debug
> engine and not having them in sync with the gui debug menu checkboxes. I
> have fixed this for our use and have attached the updated Main.java
> file. The change simply sets the checkbox selected state along with the
> dim flags.
Patch for wrapping unchecked exceptions from Java method invocations
Recently we had a problem with a NPE occurring in a Java method - it wasn't
wrapped into WrappedException and subsequently we did not see the interpreter
script stack traces. This is because unchecked throwables aren't wrapped into
InvocationTargetException. I changed the relevant code in MemberBox.java to
wrap all exceptions (checked and unchecked) into WrappedException. BTW, this is
now consistent with how JavaMembers.get() and JavaMembers.put() work - they
also wrap all exceptions into WrappedException, not just
InvocationTargetException.
"Scriptable target" argument to Ref.(get|set|has|delete) methods. The idea was
to optimize away in many cases creation of Ref instances, but given that modern
JVM can GC short-lived objects efficiently it does not sound right to have code
complexity now in the hope of slightly more efficient implementation later.
I assume "functionName" in BaseFunction could also undergo a similar treatment
of being replaced with an abstract getFunctionName() method, couldn't it? The
function name is either calculable from other data (FieldAndMethods, overloaded
case of NativeJavaMethod*, NativeJavaConstructor, InterpetedFunction) or fixed
(NativeRegExpCtor) in lots of subclasses.
While investigating how Rhino loads Java packages I came across what
appears to be a "typo" bug in NativeJavaTopPackage.java; a missing
semicolon in a string results in minor performance degradation for
script accessing the java.lang.reflect and java.lang.io packages.
In this way when native code implementing host objects calls Context.jsToJava the exception can be caught in JS and processed in in the same way as exceptions resulting from bad calls to LiveConnect Java objects.
Rhino never claimed to support binary compatibility in the serialized objects and it is better to use the system generated ids always to catch errors about incompatible changes ASAP.
1. IdScriptableObject.maxInstanceId is replaced by overridden getMaxInstanceId()
2. BaseFunction.argumentsProperty is replaced by storing when necessary explicit "arguments" property in ScriptableObject hashmap.
3. NativeFunction.(argNames|argCount|version) is replaced by code that reconstruct the necessary values from embedded in class file or InterpreterData (see bug 264637)
-------- Original Message --------
Subject: RE: www.mozilla.org/rhino: NPL license Messages_fr.properties?
Date: Fri, 8 Oct 2004 13:52:39 -0400
From: Aresteanu, Eugene <eugenea@avivasolutions.com>
To: 'Igor Bukanov' <igor@fastmail.fm>
Hi Igor,
Yes, I agree,
Eugene Aresteanu
Do you agree to change the license as expressed in the license header
for the file:
mozilla/js/rhino/src/org/mozilla/javascript/resources/Messages_fr.properties
located at cvs.mozilla.org:/cvsroot to the following text:
#
# French JavaScript messages file.
#
# 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 Aviva Inc. code, released March 5, 2004.
#
# The Initial Developer of the Original Code is Aviva Inc.
# Portions created by Aviva Inc. are Copyright (C) 2004 Aviva Inc.
# All Rights Reserved.
#
# Contributor(s):
# Eugene Aresteanu
#
# 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.
The change shall apply only to CVS HEAD version of the file.
-------- Original Message --------
Subject: Re: www.mozilla.org/rhino: Changing the license for Delegator
Date: Fri, 08 Oct 2004 16:08:01 +0100
From: Matthias Radestock <matthias@sorted.org>
To: Igor Bukanov <igor@fastmail.fm>
References: <41668055.2050404@fastmail.fm> <4166830A.3010900@sorted.org> <4166AD80.6070806@fastmail.fm>
Igor Bukanov wrote:
> Thanks, I would like to change the license header from the current:
>
> /* -*- 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/
> *
> * 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 Delegator.java, released Sep 27, 2000.
> *
> * The Initial Developer of the Original Code is Matthias Radestock.
> * <matthias@sorted.org>. Portions created by Matthias Radestock are
> * Copyright (C) 2000 Matthias Radestock. All Rights Reserved.
> *
> * Contributor(s):
> * Redfig Ltd (http://www.redfig.com)
> * LShift Ltd (http://www.lshift.net)
> *
> * Alternatively, the contents of this file may be used under the terms
> * of the GNU Public License (the "GPL License"), in which case the
> * provisions of the GPL License 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 License and not to allow others to use
> * your version of this file under the MPL, indicate your decision by
> * deleting the provisions above and replace them with the notice and
> * other provisions required by the GPL License. If you do not delete
> * the provisions above, a recipient may use your version of this file
> * under either the MPL or the GPL License.
> */
>
>
> to the following one:
>
>
> /* -*- 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 Delegator.java, released Sep 27, 2000.
> *
> * The Initial Developer of the Original Code is Matthias Radestock.
> * <matthias@sorted.org>. Portions created by Matthias Radestock are
> * Copyright (C) 2000 Matthias Radestock. All Rights Reserved.
> *
> * Contributor(s):
> *
> * Matthias Radestock, Redfig Ltd (http://www.redfig.com)
> * Matthias Radestock, LShift Ltd (http://www.lshift.net)
> *
> * 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.
> */
>
>
>
> Note that the new version replaces:
>
> * Contributor(s):
> * Redfig Ltd (http://www.redfig.com)
> * LShift Ltd (http://www.lshift.net)
>
> by the following text:
>
> * Contributor(s):
> *
> * Matthias Radestock, Redfig Ltd (http://www.redfig.com)
> * Matthias Radestock, LShift Ltd (http://www.lshift.net)
>
> since Contributors section should contain at lease the name of the
> person contributing.
>
> If it is Ok, then I need your authorisation to perform such license
> change for the following files:
>
> mozilla/js/rhino/src/org/mozilla/javascript/Delegator.java
> mozilla/js/rhino/src/org/mozilla/javascript/.java
>
> located at the CVS repository at cvs.mozilla.org:/cvsroot
>
> The license change shall apply only to the CVS HEAD version of the files.
>
Igor,
that's all fine. Go ahead and make the changes.
Matthias.
References now are represented by the pairs (ref, ref_target) where ref is Ref (former Reference) instance and ref_target is Scriptable to apply the reference for.
To return the pair from Reference creation function Context.scratchRefTarget is used to store the target part.
This change allowed to extend XMLName from Ref eliminating the need for XMLReference.
I changes just added toObject(Contetx cx, Object obj) to
toObjectOrNull(Contetx cx, Object obj) which returns null when obj is undefined
or null. It forces the caller to check to the return status but then much
better error report can be generated since the caller knows the operation that was called upon the undefined or null value.
To implement the function call redirection functionality XMLObject.getExtraMethodSource is added() to return an additional object to use as method source.
List of the affected files:
mozilla/js/rhino/src/org/mozilla/javascript/Callable.java
mozilla/js/rhino/src/org/mozilla/javascript/ClassCache.java
mozilla/js/rhino/src/org/mozilla/javascript/CompilerEnvirons.java
mozilla/js/rhino/src/org/mozilla/javascript/ContextAction.java
mozilla/js/rhino/src/org/mozilla/javascript/ContextFactory.java
mozilla/js/rhino/src/org/mozilla/javascript/Kit.java
mozilla/js/rhino/src/org/mozilla/javascript/Reference.java
mozilla/js/rhino/src/org/mozilla/javascript/SpecialRef.java
mozilla/js/rhino/toolsrc/org/mozilla/javascript/tools/debugger/GuiCallback.java
mozilla/js/rhino/toolsrc/org/mozilla/javascript/tools/debugger/test.js
mozilla/js/rhino/xmlimplsrc/org/mozilla/javascript/xmlimpl/XMLReference.java
Please contact igor@runitsoft.com if you have any questions about this.
Signatures in Reference are changed to include Context and reference-related methods in ScriptRuntime accept/return explicit Reference type instead of generic Object as code generation ensure proper type.
2. x..y use explicit reference instead of special descendants mark XMLName:
In this way less code is necessary to support x..y operations and support for .. in non-xml objects is possible.
to check for strict mode.
2. Fix name lokup bug in XMLReference that caused in cases like
foo.(@bar == 'something') to throw runtime exception if bar attribute
does not exist in foo.
perform type conversion checks for methods that do return proper JS type the
type check is done only once in the constructor and if necessary a flag is set
to call WrapFaactory.wrap on method return.
2. Use linked list of read-only REPogState to implement state stack instead of array of struct. It fixes bug 258417 while making creation of back track stack data much cheaper since there is no need to copy read-only structures.
processes breakpoint hit and another breakpoint is met during event processing,
then on Linux recursive invocations of EventQueue.getNextEvent()/dispatchEvent
lead to eventual GUI deadlock. It is easy to observe when the break on function
enter is enabled and a JS function is called that is attached to an action
handler of some button. With recursive bahaviour repeated clicks lead to deeper
and deeper invocation of EventQueue.getNextEvent() and GUI deadlock on Linux.
So to improve debugger stubility I modify Dim.interrupted to ignore calls from
event thread when another invocation of Dim.interrupted already waits for GUI
result.
2. To decrease class and jar bloat I merges various implementations of Runnable
and and other interfaces to single class with switch dispatch. It saved about
6K from js.jar.
2. Removal of never used NativeCall.thisObj field and code to initialize it.
3. Renaming NativeCall.funObj to NativeCall.function for better readability.
1. Fix to pass to debugger wrapped frame.resultDbl if frame.result is DBL_MARK
2. Change Interpreter.interpret to return the properly wrapped result instead of the final frame.
3. Use Object for throwable variable in Interpreter.interpret to avoid multiple casts to Throwable
ScriptableObject to use EvaluatorException instead.
For greater compatibility I also changed ClassDefinitionException to extend
from RuntimeException, not Exception so compilers would not complain about
"catch (ClassDefinitionException ex)" when no ClassDefinitionException is present in the called code.
JavaSriptException now inherits from RhinoException which inherits from RuntimeException and as such it does not necessary to declare it.
Moreover, it is wrong to use it for the documentation purpose since a script can also throw EcmaError and WrappedException and a proper documentation would require to document those exceptions as well. But since almost all Rhino functions can potentially execute script code it means that wast majority of functions would bear the declarations, not only code overriding or calling explicitly Function.call/construct. And then the throw declarations would bring no information if it always would be "throws RhinoException". Thus it is better not to litter sources with the declarations at all.
functions declared inside with statements to ensure that their thisObj
is not with or call scope as required by ECMA-262.
But due the changes to support E4X extensions such situation can only happen
when function is accessed as expression like in
var f = function() { }
...
f()
and typically it is exactly nested the functions that are accessed in this way.
So the patch adds optimized code that always check for proper thisObj to
ScriptRuntime.getValueFunctionAndThis and removes getThis and corresponding parsing/code generation code.
In this way when nested functions are accessed as name or property no checks are done for them and Rhino code slightly shrinks.
Do not scan regexp literals in TokenStream.getToken(). Instead parser will call explicit TokenStream.readRegExp() after it gets / or /= as primary expression. In this way there is no need to use any explicit regexp flags which rather error prone.
The change required to move security domain information form InterpreterData to its Scriptable wrappers. To simplify it and to make the interpreted functions to behave exactly as class compiled I merged InterpretedScript into InterpretedFunction which allowed to remove many casts and discrepancies when handling script and function instances.
2. Explicitly passing Interpreter instances to Context.compile... functions to avoid changing optimization level even temporarily.
3. Uniform initialization of class compiled and interpreted functions and scripts to avoid code duplication.
Since changes to fix bug 254778 made the parser the sole source of syntax error reports, it removed the need to check for errors after tree transformation.
The patch removes those checks and moves all reporting about syntax errors into omj/Parser.java.
Since E4X implementation needs to know the activation scope for tracking of default namespaces, previously an elaborated schema was added to set/restore the activation scope which relied on the fact that scrip and function with activation record should always call special entry/exit functions.
But that does not work for functions without activation records since they never call any special entry/exit pairs. So if application call such function directly, the function would not store its top scope anywhere and the E4X subsystem would not be able to get E4X library object.
The patch fixes with introduction of 2 functions, hasTopCall and doTopCall to ScriptRuntime and adding the following code prefix to each implementation of Callable.call that can start execution of script code:
public Object call(Context cx, Scriptable scope,
Scriptable thisObj, Object[] args)
throws JavaScriptException
{
// Prefix start
if (!ScriptRuntime.hasTopCall(cx)) {
return ScriptRuntime.doTopCall(this, cx, scope, thisObj, args);
}
// Prefix end
...
In this way there is always registered top scope during script execution and the previous elaborated schema became unnecessary so I reverted that part to almost pre-E4x state.
2. xml/XMLObject do not define lib() method and instead defines few abstract methods to create "with" proxies and perform addition.
3. XMLLib implementation is stored in the scope using ScriptableObject.associateValue() and does not depend on presence of proper XML object.
ScriptRuntime.get(Name|Prop|Elem|Value)FunctionAndThis provides uniform way to get function object and its this during function calls. It allowed to simplify handling of method calls both in interpreter and optimizer and opened a way to implement independent processing of function and property namespaces.
it has to be updated. This is done for Rhino classes and since IdScriptable
is not a part of public API, it should not matter. But in reality someone can
subclass IdScriptable in application code.
To help with upgrade in such cases I renamed IdScriptable into
IdScriptableObject. In this way the application using IdScriptable code can add
old IdScriptable class to its CLASSPATH and be able to run again without the
need to recompile/change anything in the source.
This is based on code contributed to Rhino by AgileDelta, Inc, www.agiledelta.com and in particular by
Ethan Hugg
Terry Lucas
Milen Nankov
John Schneider
Thanks!
This is based on code contributed to Rhino by AgileDelta, Inc, www.agiledelta.com and in particular by
Ethan Hugg
Terry Lucas
Milen Nankov
John Schneider
Thanks!
The new logic introduces 2 independent id namespaces, instance ids and prototype ids. Typically there are very few instance properties and instance ids corresponds exactly to them. The prototype ids allows to define functions and other constant objects that typically found in prototype objects.
The new implementation takes advantage of this difference to provide very different API to implement fast mapping both for instance and prototype ids.
2. Start of the changes for simpler to use IdScriptable implementation: new utility functions in IdFunction and removal of Context argument from IdScriptable.fillConstructorProperties.