Skip to content
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

StringBuilder/Buffer support in scripting broken #496

Closed
p-bakker opened this issue Dec 17, 2018 · 2 comments · Fixed by #1210
Closed

StringBuilder/Buffer support in scripting broken #496

p-bakker opened this issue Dec 17, 2018 · 2 comments · Fixed by #1210

Comments

@p-bakker
Copy link
Collaborator

I think due to 141dc4f#diff-8f122a374db26c040ca0460f9c5b4541L1015 it is no longer possible to utilize StringBuffer/Builder in JavaScript, as all instances of CharSequence become ConString instances or something.

While I understand that the ConString optimization alleviates the need to use StringBuffer/Builder, it breaks existing code and makes inline Java code clumsy, for example the implementation of the characters method of org.xml.sax.helpers.DefaultHandler now looks something like cellValue += new java.lang.String["(char[])"](chars.slice(start, start + length)), whereas before it looked like cellValue.append(chars, start, length)

@gbrail
Copy link
Collaborator

gbrail commented Jan 3, 2019

I can understand this this changed things. However that particular change was merged in 2011 and it'd probably make things worse in different ways to change it now.

As I recall the Nashorn Engine in Java 8 and 9 does the same thing, and in fact that bit of it was written by the same developer.

ConsString does include a toString() method which flattens the string if it needs flattening...

@p-bakker
Copy link
Collaborator Author

See renewed discussion here

@p-bakker p-bakker linked a pull request Apr 21, 2022 that will close this issue
shelches pushed a commit to shelches/rhino that referenced this issue Apr 25, 2022
shelches pushed a commit to shelches/rhino that referenced this issue Apr 25, 2022
shelches pushed a commit to shelches/rhino that referenced this issue May 19, 2022
shelches pushed a commit to shelches/rhino that referenced this issue May 20, 2022
shelches pushed a commit to shelches/rhino that referenced this issue May 23, 2022
gbrail pushed a commit that referenced this issue May 27, 2022
Convert non-String, non-ConsString objects to a string when creating a ConsString so that StringBuilders and other CharSequence objects can be used natively more easily.

Fixes #1206 and #496

Co-authored-by: Edward Jensen <[email protected]>
jcompagner pushed a commit to Servoy/rhino that referenced this issue Aug 10, 2023
…ozilla#1210)

Convert non-String, non-ConsString objects to a string when creating a ConsString so that StringBuilders and other CharSequence objects can be used natively more easily.

Fixes mozilla#1206 and mozilla#496

Co-authored-by: Edward Jensen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants