зеркало из https://github.com/mozilla/pjs.git
Fix bug 49325.
This commit is contained in:
Родитель
d55dd0cde5
Коммит
c1c435731a
|
@ -288,19 +288,23 @@ public class JavaAdapter extends ScriptableObject {
|
||||||
public static Object callMethod(Scriptable object, String methodId,
|
public static Object callMethod(Scriptable object, String methodId,
|
||||||
Object[] args)
|
Object[] args)
|
||||||
{
|
{
|
||||||
if (object.has(methodId, object)) {
|
|
||||||
try {
|
try {
|
||||||
Context cx = Context.enter();
|
Context cx = Context.enter();
|
||||||
Object fun = object.get(methodId, object);
|
Object fun = ScriptableObject.getProperty(object,methodId);
|
||||||
|
if (fun == Scriptable.NOT_FOUND) {
|
||||||
|
// It is an error that this function doesn't exist.
|
||||||
|
// Easiest thing to do is just pass the undefined value
|
||||||
|
// along and ScriptRuntime will take care of reporting
|
||||||
|
// the error.
|
||||||
|
fun = Undefined.instance;
|
||||||
|
}
|
||||||
return ScriptRuntime.call(cx, fun, object, args, object);
|
return ScriptRuntime.call(cx, fun, object, args, object);
|
||||||
} catch (JavaScriptException ex) {
|
} catch (JavaScriptException ex) {
|
||||||
// TODO: could occur
|
throw WrappedException.wrapException(ex);
|
||||||
} finally {
|
} finally {
|
||||||
Context.exit();
|
Context.exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Context.getUndefinedValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Scriptable toObject(Object value, Scriptable scope,
|
public static Scriptable toObject(Object value, Scriptable scope,
|
||||||
Class staticType)
|
Class staticType)
|
||||||
|
@ -609,12 +613,11 @@ public class JavaAdapter extends ScriptableObject {
|
||||||
"Ljava/lang/String;[Ljava/lang/Object;)",
|
"Ljava/lang/String;[Ljava/lang/Object;)",
|
||||||
"Ljava/lang/Object;");
|
"Ljava/lang/Object;");
|
||||||
|
|
||||||
Class retType = returnType;
|
if (returnType.equals(Void.TYPE)) {
|
||||||
if (retType.equals(Void.TYPE)) {
|
|
||||||
cfw.add(ByteCode.POP);
|
cfw.add(ByteCode.POP);
|
||||||
cfw.add(ByteCode.RETURN);
|
cfw.add(ByteCode.RETURN);
|
||||||
} else {
|
} else {
|
||||||
generateReturnResult(cfw, retType);
|
generateReturnResult(cfw, returnType);
|
||||||
}
|
}
|
||||||
cfw.stopMethod((short)(scopeLocal + 1), null);
|
cfw.stopMethod((short)(scopeLocal + 1), null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -288,19 +288,23 @@ public class JavaAdapter extends ScriptableObject {
|
||||||
public static Object callMethod(Scriptable object, String methodId,
|
public static Object callMethod(Scriptable object, String methodId,
|
||||||
Object[] args)
|
Object[] args)
|
||||||
{
|
{
|
||||||
if (object.has(methodId, object)) {
|
|
||||||
try {
|
try {
|
||||||
Context cx = Context.enter();
|
Context cx = Context.enter();
|
||||||
Object fun = object.get(methodId, object);
|
Object fun = ScriptableObject.getProperty(object,methodId);
|
||||||
|
if (fun == Scriptable.NOT_FOUND) {
|
||||||
|
// It is an error that this function doesn't exist.
|
||||||
|
// Easiest thing to do is just pass the undefined value
|
||||||
|
// along and ScriptRuntime will take care of reporting
|
||||||
|
// the error.
|
||||||
|
fun = Undefined.instance;
|
||||||
|
}
|
||||||
return ScriptRuntime.call(cx, fun, object, args, object);
|
return ScriptRuntime.call(cx, fun, object, args, object);
|
||||||
} catch (JavaScriptException ex) {
|
} catch (JavaScriptException ex) {
|
||||||
// TODO: could occur
|
throw WrappedException.wrapException(ex);
|
||||||
} finally {
|
} finally {
|
||||||
Context.exit();
|
Context.exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Context.getUndefinedValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Scriptable toObject(Object value, Scriptable scope,
|
public static Scriptable toObject(Object value, Scriptable scope,
|
||||||
Class staticType)
|
Class staticType)
|
||||||
|
@ -609,12 +613,11 @@ public class JavaAdapter extends ScriptableObject {
|
||||||
"Ljava/lang/String;[Ljava/lang/Object;)",
|
"Ljava/lang/String;[Ljava/lang/Object;)",
|
||||||
"Ljava/lang/Object;");
|
"Ljava/lang/Object;");
|
||||||
|
|
||||||
Class retType = returnType;
|
if (returnType.equals(Void.TYPE)) {
|
||||||
if (retType.equals(Void.TYPE)) {
|
|
||||||
cfw.add(ByteCode.POP);
|
cfw.add(ByteCode.POP);
|
||||||
cfw.add(ByteCode.RETURN);
|
cfw.add(ByteCode.RETURN);
|
||||||
} else {
|
} else {
|
||||||
generateReturnResult(cfw, retType);
|
generateReturnResult(cfw, returnType);
|
||||||
}
|
}
|
||||||
cfw.stopMethod((short)(scopeLocal + 1), null);
|
cfw.stopMethod((short)(scopeLocal + 1), null);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче