RFR: 8301065: Handle control characters in java_lang_String::print [v2]

Ioi Lam iklam at openjdk.org
Tue Apr 18 15:59:33 UTC 2023


On Tue, 18 Apr 2023 07:42:49 GMT, David Holmes <dholmes at openjdk.org> wrote:

> > We actually have some intentional use of non printable characters. For example, for string concatenation like this:
> > ```
> > String x = ....;
> > String s = "abc" + x + "xyz";
> > ```
> > 
> > 
> >     
> >       
> >     
> > 
> >       
> >     
> > 
> >     
> >   
> > We'll pass a parameter to the `StringConcatFactory.makeConcatWithConstants()` bootstrap method that looks like this:
> > ```
> > "abc\u0001xyz"
> > ```
> 
> That doesn't seem a valid thing to do as string literals could contain any character, including \u0001. ??

String literals that contain special characters are passed as separate bootstrap arguments, and are marked by \u0002 in the first bootstrap argument to  `StringConcatFactory.makeConcatWithConstants()`. You can see the implementation of StringConcatFactory for details.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/12190#issuecomment-1513415986


More information about the hotspot-runtime-dev mailing list