Fix bug where conversions of numbers to booleans in calls to Java methods were producing

IllegalArgumentExceptions.
This commit is contained in:
norris%netscape.com 1999-04-29 17:53:05 +00:00
Родитель 37a5770275
Коммит 02d3b99592
4 изменённых файлов: 10 добавлений и 2 удалений

Просмотреть файл

@ -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