-
Notifications
You must be signed in to change notification settings - Fork 859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ConsString.flattend should not cast to a String but call toString() instead #1368
Comments
any chance to provide a test case (see org.mozilla.javascript.tests.ConsStringTest) |
|
this was fixed with #1210 - do you use the latest code? |
ah i was still using our source (and testing against that) and that was build from version 1.7.14 (and i noticed the cast so i didn't look really further because i still saw that same code. Edit: and i see now that 1.7.14 is still the latest release so thats i guess why i didn't notice it.. |
https://github.com/mozilla/rhino/blob/master/src/org/mozilla/javascript/ConsString.java#L78
everywhere in ConsString left, right are CharSequence objects
so it can be that from java when you append code the java method returns a StringBuilder object and that is fine for ConsString for a long time until it wants to flatten then it bombs out with a classcast because we assume all charsequences (left/right) are or a ConsString or a String, but there are more implementations of CharSequnce.
so that code i think should just be changed to:
final String str = next.toString();
to make it a string, if it is a string there is no effect that just returns itself so that is just as fast.
The text was updated successfully, but these errors were encountered: