It really doesn't make any sense. If it were a compile-time constant that you didn't need to pull back to String , then that would make a little more sense. You still have a character encoding problem.
It would be more reasonable to me if it were constant char[] . In the real world, there are several JSP compilers that optimize String constants in char[] , which, in turn, can be easily written in Writer#write(char[]) . This is ultimately a bit more efficient. but these little cue ball are a lot of interesting in large and heavily used applications such as Google Search, etc.
The Tomcat JSP Jasper compiler does this as well. Check the setting of genStringAsCharArray . So he does it
static final char[] text1 = "some static text".toCharArray();
instead
static final String text1 = "some static text";
which ends up with less overhead. These characters do not require an entire String instance.
Balusc
source share