From 3d6da7803dcb8e83c39409626ef26a87797b89c4 Mon Sep 17 00:00:00 2001 From: hns Date: Thu, 18 Aug 2005 22:41:00 +0000 Subject: [PATCH] * Synchronize get() and set() to hopefully get rid of weird property read errors. * Do not access static fields through instance variable --- src/helma/scripting/rhino/GlobalObject.java | 23 ++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/helma/scripting/rhino/GlobalObject.java b/src/helma/scripting/rhino/GlobalObject.java index 36ddfe7d..f1707e96 100644 --- a/src/helma/scripting/rhino/GlobalObject.java +++ b/src/helma/scripting/rhino/GlobalObject.java @@ -85,12 +85,25 @@ public class GlobalObject extends ImporterTopLevel implements PropertyRecorder { } /** - * Override ScriptableObject.put() to implement PropertyRecorder interface. + * Override ScriptableObject.get() to synchronize it. + * + * @param name + * @param start + * @return the property for the given name + */ + public synchronized Object get(String name, Scriptable start) { + return super.get(name, start); + } + + /** + * Override ScriptableObject.put() to implement PropertyRecorder interface + * and to synchronize method. + * * @param name * @param start * @param value */ - public void put(String name, Scriptable start, Object value) { + public synchronized void put(String name, Scriptable start, Object value) { // register property for PropertyRecorder interface if (isRecording) { changedProperties.add(name); @@ -519,7 +532,7 @@ public class GlobalObject extends ImporterTopLevel implements PropertyRecorder { "the serialization to"); } Object obj = args[0]; - String filename = cx.toString(args[1]); + String filename = Context.toString(args[1]); FileOutputStream fos = new FileOutputStream(filename); Scriptable scope = ScriptableObject.getTopLevelScope(thisObj).getPrototype(); // use a ScriptableOutputStream that unwraps Wrappers @@ -542,13 +555,13 @@ public class GlobalObject extends ImporterTopLevel implements PropertyRecorder { throw Context.reportRuntimeError( "Expected a filename to read the serialization from"); } - String filename = cx.toString(args[0]); + String filename = Context.toString(args[0]); FileInputStream fis = new FileInputStream(filename); Scriptable scope = ScriptableObject.getTopLevelScope(thisObj).getPrototype(); ObjectInputStream in = new ScriptableInputStream(fis, scope); Object deserialized = in.readObject(); in.close(); - return cx.toObject(deserialized, scope); + return Context.toObject(deserialized, scope); }