diff --git a/src/org/mozilla/javascript/ConsString.java b/src/org/mozilla/javascript/ConsString.java index d90e47be77..4513fbe899 100644 --- a/src/org/mozilla/javascript/ConsString.java +++ b/src/org/mozilla/javascript/ConsString.java @@ -32,6 +32,12 @@ public class ConsString implements CharSequence, Serializable { private boolean isFlat; public ConsString(CharSequence str1, CharSequence str2) { + if (!(str1 instanceof String) && !(str1 instanceof ConsString)) { + str1 = str1.toString(); + } + if (!(str2 instanceof String) && !(str2 instanceof ConsString)) { + str2 = str2.toString(); + } left = str1; right = str2; length = left.length() + right.length(); @@ -69,7 +75,7 @@ private synchronized String flatten() { } } - final String str = next.toString(); + final String str = (String) next; charPos -= str.length(); str.getChars(0, str.length(), chars, charPos); next = stack.isEmpty() ? null : stack.removeFirst();