Map overrides = args.length > 1 && args[1] instanceof Map ?
(Map)args[1] : null;
try {
Class<?> adapterClass = getAdapterClass(classes, overrides);
Scriptable scope = getTopLevelScope(function);
RhinoEngine engine = RhinoEngine.getEngine(scope);
Constructor cnst = adapterClass.getConstructor(EventAdapter.class);
EventAdapter adapter = new EventAdapter(engine);
adapter.impl = cnst.newInstance(adapter);
return adapter;
} catch (Exception ex) {