diff --git a/js/rhino/src/org/mozilla/javascript/ImporterTopLevel.java b/js/rhino/src/org/mozilla/javascript/ImporterTopLevel.java index 0301d34d8db4..af173828f8d8 100644 --- a/js/rhino/src/org/mozilla/javascript/ImporterTopLevel.java +++ b/js/rhino/src/org/mozilla/javascript/ImporterTopLevel.java @@ -97,10 +97,21 @@ public class ImporterTopLevel extends ScriptableObject { return "global"; } + public boolean has(String name, Scriptable start) { + return super.has(name, start) + || getPackageProperty(name, start) != NOT_FOUND; + } + public Object get(String name, Scriptable start) { Object result = super.get(name, start); if (result != NOT_FOUND) return result; + result = getPackageProperty(name, start); + return result; + } + + private Object getPackageProperty(String name, Scriptable start) { + Object result= NOT_FOUND; if (name.equals("_packages_")) return result; Object plist = ScriptableObject.getProperty(start,"_packages_"); diff --git a/js/rhino/src/org/mozilla/javascript/NativeJavaPackage.java b/js/rhino/src/org/mozilla/javascript/NativeJavaPackage.java index e5317116dff9..210347f6694b 100644 --- a/js/rhino/src/org/mozilla/javascript/NativeJavaPackage.java +++ b/js/rhino/src/org/mozilla/javascript/NativeJavaPackage.java @@ -178,10 +178,14 @@ public class NativeJavaPackage extends ScriptableObject { return "JavaPackage"; } - public boolean has(String id, int index, Scriptable start) { + public boolean has(String id, Scriptable start) { return true; } + public boolean has(int index, Scriptable start) { + return false; + } + public void put(String id, Scriptable start, Object value) { // Can't add properties to Java packages. Sorry. }