Added documentation strings for runCommnad and spawn is changed to pass empty argument array instead of null if function arguments are not specified to avoid a null pointer exception in InterpretedFunction.call

This commit is contained in:
igor%mir2.org 2003-01-26 18:28:26 +00:00
parent 7129e5491a
commit ae4b000c3f
2 changed files with 11 additions and 2 deletions

View File

@ -129,6 +129,12 @@ msg.must.implement.Script =\
the Script interface. Class files generated by compiling scripts \
will implement Script.
msg.runCommand.bad.args =\
The first argument to runCommand must be a command name.
msg.runCommand.bad.env =\
A value of the env property of option object for runCommnad must be an \
object.
msg.idswitch.same_string =\
The string {0} is used second time in the switch code. \
@ -184,3 +190,4 @@ Note: the original file will be overwritten without any backup actions\n\
msg.idswitch.version = \
org.mozilla.javascript.tools.idswitch.StringIdMap version 0.2

View File

@ -20,6 +20,7 @@
*
* Contributor(s):
* Patrick Beard
* Igor Bukanov
* Norris Boyd
* Rob Ginda
* Kurt Westerfeld
@ -295,6 +296,7 @@ public class Global extends ImporterTopLevel {
if (args.length > 1 && args[1] instanceof Scriptable) {
newArgs = cx.getElements((Scriptable) args[1]);
}
if (newArgs == null) { newArgs = ScriptRuntime.emptyArgs; }
runner = new Runner(scope, (Function) args[0], newArgs);
} else if (args.length != 0 && args[0] instanceof Script) {
runner = new Runner(scope, (Script) args[0]);
@ -377,7 +379,7 @@ public class Global extends ImporterTopLevel {
{
int L = args.length;
if (L == 0 || (L == 1 && args[0] instanceof Scriptable)) {
throw reportRuntimeError("msg.system.args");
throw reportRuntimeError("msg.runCommand.bad.args");
}
InputStream in = null;
@ -396,7 +398,7 @@ public class Global extends ImporterTopLevel {
environment = new String[0];
} else {
if (!(envObj instanceof Scriptable)) {
throw reportRuntimeError("msg.system.args");
throw reportRuntimeError("msg.runCommand.bad.env");
}
Scriptable envHash = (Scriptable)envObj;
Object[] ids = ScriptableObject.getPropertyIds(envHash);