From cd3fdb4fab6a8d8dad0166188400a587b35a3c9b Mon Sep 17 00:00:00 2001 From: hns Date: Fri, 16 Sep 2005 00:34:12 +0000 Subject: [PATCH] * Fix prototype inheritance for wrapped Java objects. get() and has() are not supposed to check the prototype chain. Instead, just register the prototype using setPrototype(). --- src/helma/scripting/rhino/JavaObject.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/helma/scripting/rhino/JavaObject.java b/src/helma/scripting/rhino/JavaObject.java index eb3a8401..48619507 100644 --- a/src/helma/scripting/rhino/JavaObject.java +++ b/src/helma/scripting/rhino/JavaObject.java @@ -31,7 +31,6 @@ import java.io.IOException; public class JavaObject extends NativeJavaObject { RhinoCore core; - Scriptable prototype; String protoName; static HashMap overload; @@ -56,13 +55,12 @@ public class JavaObject extends NativeJavaObject { this.parent = scope; this.javaObject = obj; this.protoName = protoName; - this.prototype = prototype; this.core = core; staticType = obj.getClass(); + setPrototype(prototype); initMembers(); } - /** * * @@ -162,13 +160,20 @@ public class JavaObject extends NativeJavaObject { return core.postProcessHref(javaObject, protoName, basicHref); } + /** + * Checks whether the given property is defined in this object. + */ public boolean has(String name, Scriptable start) { // System.err.println ("HAS: "+name); - if (prototype.has(name, start)) + if (overload.containsKey(name)) { return true; + } return super.has(name, start); } + /** + * Get a named property from this object. + */ public Object get(String name, Scriptable start) { // System.err.println ("GET: "+name); Object obj = overload.get(name); @@ -176,11 +181,6 @@ public class JavaObject extends NativeJavaObject { return new FunctionObject(name, (Method) obj, this); } - obj = prototype.get(name, start); - if (obj != null && obj != NOT_FOUND) { - return obj; - } - return super.get(name, start); }