diff --git a/mozilla/js/rhino/src/org/mozilla/javascript/NativeJavaPackage.java b/mozilla/js/rhino/src/org/mozilla/javascript/NativeJavaPackage.java index e1221fbe387..cce34d0050c 100644 --- a/mozilla/js/rhino/src/org/mozilla/javascript/NativeJavaPackage.java +++ b/mozilla/js/rhino/src/org/mozilla/javascript/NativeJavaPackage.java @@ -210,27 +210,22 @@ public class NativeJavaPackage extends ScriptableObject { : packageName + "." + name; Context cx = Context.getContext(); ClassShutter shutter = cx.getClassShutter(); - Scriptable newValue; - try { - if (shutter != null && !shutter.visibleToScripts(newPackage)) - throw new ClassNotFoundException(); - Class newClass = classLoader != null - ? classLoader.loadClass(newPackage) - : ScriptRuntime.loadClassName(newPackage); - newValue = new NativeJavaClass(getTopLevelScope(this), newClass); - newValue.setParentScope(this); - newValue.setPrototype(this.prototype); - } catch (ClassNotFoundException ex) { - if (createPkg) { - NativeJavaPackage pkg = new NativeJavaPackage(newPackage, - classLoader); - pkg.setParentScope(this); - pkg.setPrototype(this.prototype); - newValue = pkg; - } else { - newValue = null; + Scriptable newValue = null; + if (shutter == null || shutter.visibleToScripts(newPackage)) { + Class cl = findClass(classLoader, newPackage); + if (cl != null) { + newValue = new NativeJavaClass(getTopLevelScope(this), cl); + newValue.setParentScope(this); + newValue.setPrototype(this.prototype); } } + if (newValue == null && createPkg) { + NativeJavaPackage pkg = new NativeJavaPackage(newPackage, + classLoader); + pkg.setParentScope(this); + pkg.setPrototype(this.prototype); + newValue = pkg; + } if (newValue != null) { // Make it available for fast lookup and sharing of // lazily-reflected constructors and static members. @@ -277,6 +272,19 @@ public class NativeJavaPackage extends ScriptableObject { Context.getMessage0("msg.not.java.obj")); } + private static Class findClass(ClassLoader loader, String className) { + try { + if (loader != null) { + return loader.loadClass(className); + } else { + return ScriptRuntime.loadClassName(className); + } + } catch (ClassNotFoundException ex) { + } catch (SecurityException ex) { + } + return null; + } + private String packageName; private ClassLoader classLoader; }