global = (GlobalObject) context.initStandardObjects(g);
global = (DynamicGlobalObject) context.initStandardObjects(g);
    public RhinoCore(Application app) {        this.app = app;        // wrappercache = new CacheMap(500, .75f);        wrappercache = new CacheMap(500);        prototypes = new Hashtable();        Context context = Context.enter();        context.setCompileFunctionsWithDynamicScope(true);        context.setApplicationClassLoader(app.getClassLoader());        wrapper = new WrapMaker();        wrapper.setJavaPrimitiveWrap(false);        context.setWrapFactory(wrapper);        int optLevel = 0;        try {            optLevel = Integer.parseInt(app.getProperty("rhino.optlevel"));        } catch (Exception ignore) {        }        // System.err.println("Setting Rhino optlevel to " + optLevel);        context.setOptimizationLevel(optLevel);        try {            GlobalObject g = new GlobalObject(this, app);            g.init();            global = (GlobalObject) context.initStandardObjects(g);            pathProto = new PathWrapper(this);            hopObjectProto =  HopObject.init(global);            FileObject.init(global);            FtpObject.init(global);            ImageObject.init(global);            XmlRpcObject.init(global);            MailObject.init(global, app.getProperties());            // add some convenience functions to string, date and number prototypes            Scriptable stringProto = ScriptableObject.getClassPrototype(global, "String");            stringProto.put("trim", stringProto, new StringTrim());            Scriptable dateProto = ScriptableObject.getClassPrototype(global, "Date");            dateProto.put("format", dateProto, new DateFormat());            Scriptable numberProto = ScriptableObject.getClassPrototype(global, "Number");            numberProto.put("format", numberProto, new NumberFormat());            initialize();        } catch (Exception e) {            System.err.println("Cannot initialize interpreter");            System.err.println("Error: " + e);            e.printStackTrace();            throw new RuntimeException(e.getMessage());        } finally {            Context.exit();        }    }