Only set path-lookup-by-prototype if the object in the path actually does have a prototype.

Previously this threw a NullPointerException for untyped path elements.

Enabled printing of stack trace for errors within invoke().
This commit is contained in:
hns 2002-05-14 16:43:03 +00:00
parent a19a01d19b
commit 45b172f21b

View file

@ -230,11 +230,14 @@ public class FesiEvaluator {
else if ("path".equals (k)) { else if ("path".equals (k)) {
ArrayPrototype parr = new ArrayPrototype (evaluator.getArrayPrototype(), evaluator); ArrayPrototype parr = new ArrayPrototype (evaluator.getArrayPrototype(), evaluator);
List path = (List) v; List path = (List) v;
// register path elements with their prototype
for (int j=0; j<path.size(); j++) { for (int j=0; j<path.size(); j++) {
Object pathElem = path.get (j); Object pathElem = path.get (j);
ESValue wrappedElement = getElementWrapper (pathElem); ESValue wrappedElement = getElementWrapper (pathElem);
parr.putProperty (j, wrappedElement); parr.putProperty (j, wrappedElement);
parr.putHiddenProperty (app.getPrototypeName(pathElem), wrappedElement); String protoname = app.getPrototypeName (pathElem);
if (protoname != null)
parr.putHiddenProperty (protoname, wrappedElement);
} }
sv = parr; sv = parr;
} else if ("user".equals (k)) { } else if ("user".equals (k)) {
@ -259,8 +262,8 @@ public class FesiEvaluator {
String msg = x.getMessage (); String msg = x.getMessage ();
if (msg == null || msg.length() < 10) if (msg == null || msg.length() < 10)
msg = x.toString (); msg = x.toString ();
// System.err.println ("INVOKE-ERROR: "+msg); System.err.println ("INVOKE-ERROR: "+msg);
// x.printStackTrace (); x.printStackTrace ();
throw new ScriptingException (msg); throw new ScriptingException (msg);
} finally { } finally {
// remove global variables that have been added during invocation. // remove global variables that have been added during invocation.