From f7808560ee2e78d2f3d2fd24e43a32ad955530e7 Mon Sep 17 00:00:00 2001 From: "igor%mir2.org" Date: Tue, 6 May 2003 15:29:36 +0000 Subject: [PATCH] Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=204513 --- .../mozilla/javascript/NativeJavaObject.java | 25 ++++++++----------- .../org/mozilla/javascript/ScriptRuntime.java | 4 --- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/js/rhino/src/org/mozilla/javascript/NativeJavaObject.java b/js/rhino/src/org/mozilla/javascript/NativeJavaObject.java index 326fdb161df..12a51ecbfc5 100644 --- a/js/rhino/src/org/mozilla/javascript/NativeJavaObject.java +++ b/js/rhino/src/org/mozilla/javascript/NativeJavaObject.java @@ -321,17 +321,13 @@ WrapFactory#wrap(Context cx, Scriptable scope, Object obj, Class)} if (to == ScriptRuntime.StringClass) { result = 1; } - else if (to == ScriptRuntime.ObjectClass || - to == ScriptRuntime.SerializableClass || - to == ScriptRuntime.ComparableClass) - { + else if (to.isInstance(fromObj)) { result = 2; } - else if (to.isPrimitive() && to != Boolean.TYPE) { + else if (to.isPrimitive()) { if (to == Character.TYPE) { result = 3; - } - else { + } else if (to != Boolean.TYPE) { result = 4; } } @@ -549,14 +545,12 @@ WrapFactory#wrap(Context cx, Scriptable scope, Object obj, Class)} break; case JSTYPE_STRING: - if (type == ScriptRuntime.StringClass || - type == ScriptRuntime.ObjectClass || - type == ScriptRuntime.SerializableClass || - type == ScriptRuntime.ComparableClass) { + if (type == ScriptRuntime.StringClass || type.isInstance(value)) { return value; } - else if (type == Character.TYPE || - type == ScriptRuntime.CharacterClass) { + else if (type == Character.TYPE + || type == ScriptRuntime.CharacterClass) + { // Special case for converting a single char string to a // character // Placed here because it applies *only* to JS strings, @@ -568,8 +562,9 @@ WrapFactory#wrap(Context cx, Scriptable scope, Object obj, Class)} return coerceToNumber(type, value, useErrorHandler); } } - else if ((type.isPrimitive() && type != Boolean.TYPE) || - ScriptRuntime.NumberClass.isAssignableFrom(type)) { + else if ((type.isPrimitive() && type != Boolean.TYPE) + || ScriptRuntime.NumberClass.isAssignableFrom(type)) + { return coerceToNumber(type, value, useErrorHandler); } else { diff --git a/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java b/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java index 4cc845855d4..2c7a4c31fd7 100644 --- a/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java +++ b/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java @@ -84,10 +84,6 @@ public class ScriptRuntime { DateClass = classOrNull("java.util.Date"); - // It will be null under JDK 1.1 as Comparable is only since JDK 1.2 - public final static Class - ComparableClass = classOrNull("java.lang.Comparable"); - public final static Class ContextClass = classOrNull("org.mozilla.javascript.Context"), FunctionClass = classOrNull("org.mozilla.javascript.Function"),