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"),