private object Js_construct(Scriptable scope, object[] args) { Rhino.ImporterTopLevel result = new Rhino.ImporterTopLevel(); for (int i = 0; i != args.Length; ++i) { object arg = args[i]; if (arg is NativeJavaClass) { result.ImportClass((NativeJavaClass)arg); } else { if (arg is NativeJavaPackage) { result.ImportPackage((NativeJavaPackage)arg); } else { throw Context.ReportRuntimeError1("msg.not.class.not.pkg", Context.ToString(arg)); } } } // set explicitly prototype and scope // as otherwise in top scope mode BaseFunction.construct // would keep them set to null. It also allow to use // JavaImporter without new and still get properly // initialized object. result.SetParentScope(scope); result.SetPrototype(this); return result; }