jtreg adds additional backslashes in Strings that are written to System.out/err?

Jonathan Gibbons jonathan.gibbons at oracle.com
Wed Sep 15 14:35:44 UTC 2021

Separate from fixing/improving jtreg -show:<name> option and its 
command-line help (CODETOOLS-7903024), given the recent interest in this 
issue, I'll add info to the FAQ.

-- Jon

On 9/15/21 6:15 AM, Pavel Rappo wrote:
> David Holmes pointed me to this thread after I started a discussion elsewhere. Coincidentally, I stumbled upon the described jtreg behavior myself yesterday. It took me a while to figure out what was happening. When I described my finding to a colleague, Jonathan Gibbons, he suggested that if required I could read `.jtr` files using a (lesser-known?) option called `show`. This option's description is buried in help output and is not particularly clear: (Care to file a bug to improve that? File a JBS issue against Project=CODETOOLS and Subcomponent=jtreg.)
>      $ jtreg --help General Options | grep -A 3 'show:<sec'
>          -show:<section-name>
>                          Show information from a section in the results file for a
>                          test. For example, -show:rerun
>          -showGroups     Show the expansion (to files and directories) of the groups
> As far as I understand, when run with this option, jtreg does not run your test. Instead, it reads the specified section from the existing `.jtr` file and outputs the same way it would otherwise appear on the console: no escapes. You can specify System.out or System.err as such a section.
> Now, here are some details. JTHarness, which is used by jtreg, encodes special symbols it encounters in standard streams. While CR, LR and TAB are output as they are, \ is output as \\ and the rest of the escape sequences are output using the \uxxxx notation. The code I saw suggests that it is not a bug and is done on purpose. Anyhow, this is how output is stored in `.jtr` files. My understanding is that jtreg knows about that and recovers original output from `.jtr` files on demand.
> -Pavel

More information about the jtreg-use mailing list