public Object callSuperWrapped(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
try {
ScriptableObject.putProperty(thisObj, "_compile", compile);
return super.call(cx, scope, thisObj, args);
} catch (JavaScriptException e) {
if ( thisObj instanceof ModuleScope) {
String id = (String)Context.jsToJava(args[0], String.class);
ModuleScope moduleScope = (ModuleScope) thisObj;
URI base = moduleScope.getBase();
URI current = moduleScope.getUri();
URI uri = current.resolve(id + ".js/");
if (!id.startsWith("./") && !id.startsWith("../") && base != null &&
new File(uri.getPath()).exists()) {
return super.call(cx, scope, thisObj, new Object[]{uri.getPath()});
}
}
throw e;
}
}