* Only reuse Java wrapper if it actually wraps the same object.

* Rename local variable in getNodeWrapper().
This commit is contained in:
hns 2006-11-23 14:51:25 +00:00
parent f249f893c5
commit 0ca4922081

View file

@ -575,9 +575,9 @@ public final class RhinoCore implements ScopeProvider {
*/ */
public Scriptable getElementWrapper(Object e) { public Scriptable getElementWrapper(Object e) {
WeakReference ref = (WeakReference) wrappercache.get(e); WeakReference ref = (WeakReference) wrappercache.get(e);
Scriptable wrapper = ref == null ? null : (Scriptable) ref.get(); Wrapper wrapper = ref == null ? null : (Wrapper) ref.get();
if (wrapper == null) { if (wrapper == null || wrapper.unwrap() != e) {
// Gotta find out the prototype name to use for this object... // Gotta find out the prototype name to use for this object...
String prototypeName = app.getPrototypeName(e); String prototypeName = app.getPrototypeName(e);
Scriptable op = getPrototype(prototypeName); Scriptable op = getPrototype(prototypeName);
@ -592,7 +592,7 @@ public final class RhinoCore implements ScopeProvider {
wrappercache.put(e, new WeakReference(wrapper)); wrappercache.put(e, new WeakReference(wrapper));
} }
return wrapper; return (Scriptable) wrapper;
} }
/** /**
@ -603,9 +603,9 @@ public final class RhinoCore implements ScopeProvider {
return null; return null;
} }
HopObject esn = (HopObject) wrappercache.get(n); HopObject hobj = (HopObject) wrappercache.get(n);
if (esn == null) { if (hobj == null) {
String protoname = n.getPrototype(); String protoname = n.getPrototype();
@ -629,12 +629,12 @@ public final class RhinoCore implements ScopeProvider {
} }
} }
esn = new HopObject(protoname, this, n, op); hobj = new HopObject(protoname, this, n, op);
wrappercache.put(n, esn); wrappercache.put(n, hobj);
} }
return esn; return hobj;
} }
protected String postProcessHref(Object obj, String protoName, String basicHref) protected String postProcessHref(Object obj, String protoName, String basicHref)