зеркало из https://github.com/mozilla/pjs.git
Fix bug where conversions of numbers to booleans in calls to Java methods were producing
IllegalArgumentExceptions.
This commit is contained in:
Родитель
37a5770275
Коммит
02d3b99592
|
@ -145,7 +145,7 @@ public class NativeJavaMethod extends NativeFunction implements Function {
|
|||
// OPT: or pass it back somehow
|
||||
Class paramTypes[] = meth.getParameterTypes();
|
||||
|
||||
// First, we kill the lawyers. Er, marshall the args.
|
||||
// First, we marshall the args.
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
args[i] = NativeJavaObject.coerceType(paramTypes[i], args[i]);
|
||||
}
|
||||
|
|
|
@ -289,6 +289,10 @@ public class NativeJavaObject implements Scriptable, Wrapper {
|
|||
// String
|
||||
if (type == ScriptRuntime.StringClass)
|
||||
return ScriptRuntime.toString(value);
|
||||
|
||||
// Boolean
|
||||
if (type == Boolean.TYPE || type == ScriptRuntime.BooleanClass)
|
||||
return new Boolean(ScriptRuntime.toBoolean(value));
|
||||
|
||||
if (type == Character.TYPE || type == ScriptRuntime.CharacterClass) {
|
||||
// Special case for converting a single char string to a character
|
||||
|
|
|
@ -145,7 +145,7 @@ public class NativeJavaMethod extends NativeFunction implements Function {
|
|||
// OPT: or pass it back somehow
|
||||
Class paramTypes[] = meth.getParameterTypes();
|
||||
|
||||
// First, we kill the lawyers. Er, marshall the args.
|
||||
// First, we marshall the args.
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
args[i] = NativeJavaObject.coerceType(paramTypes[i], args[i]);
|
||||
}
|
||||
|
|
|
@ -289,6 +289,10 @@ public class NativeJavaObject implements Scriptable, Wrapper {
|
|||
// String
|
||||
if (type == ScriptRuntime.StringClass)
|
||||
return ScriptRuntime.toString(value);
|
||||
|
||||
// Boolean
|
||||
if (type == Boolean.TYPE || type == ScriptRuntime.BooleanClass)
|
||||
return new Boolean(ScriptRuntime.toBoolean(value));
|
||||
|
||||
if (type == Character.TYPE || type == ScriptRuntime.CharacterClass) {
|
||||
// Special case for converting a single char string to a character
|
||||
|
|
Загрузка…
Ссылка в новой задаче