This repository has been archived by the owner on Oct 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Util. stringLiteralWithDoubleQuotes should split strings > 64k #776
Comments
I faced the same problem. I used the code snippet below to solve it. Java supports string literals of size 65534. So basically split the string by length 65534 and initialise the string with string builder using CodeBlock's formatting.
|
Your code will fail if the long String being split contains a unicode escape (aka backslash u hex hex hex hex) or a backslash escape sequence (like backslash tee for tab) that starts at 65534 -1. |
Our group are interested in this issue, we will try to fix it. |
If you need strings that long, is compiled code the right format? Loading a
resource is probably a more appropriate option.
If you *really* need those strings, this is a really niche feature request
and the perfect thing for another library to supply.
…On Thu, Mar 11, 2021 at 5:59 PM CharlotteE67 ***@***.***> wrote:
Our group are interested in this issue, we will try to fix it.
---- SE_Sustech
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#776 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGBRXK2OGHR7CB6OE7QFQ3TDDSEPANCNFSM4M522IEQ>
.
|
GWT/J2Cl are two examples where this is might be the only or best choice out of many others. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
https://github.com/square/javapoet/blob/master/src/main/java/com/squareup/javapoet/Util.java
If attempting to "write" a string literal greater than 64k, the resulting source product that will fail to compile. Javac will of course complain that said string literal is too longer than 64k.
My suggestion would be to split the string into
new StringBuilder()
withappend
statements each holding a string literal that isnt over the limit.My own mini tool that accomplishes this:
https://github.com/mP1/j2cl-locale/blob/master/src/main/java/walkingkooka/j2cl/locale/annotationprocessor/LocaleAwareAnnotationProcessor.java#L171
The text was updated successfully, but these errors were encountered: