From jai.forums2013 at gmail.com Sun Aug 29 13:24:17 2021 From: jai.forums2013 at gmail.com (Jaikiran Pai) Date: Sun, 29 Aug 2021 18:54:17 +0530 Subject: jtreg adds additional backslashes in Strings that are written to System.out/err? Message-ID: <30a84ffd-7f37-3440-c820-34f2d02cf8f5@gmail.com> Please consider this trivial Java code which prints to System.out: public class FooTest { ??? public static void main(final String[] args) throws Exception { ??????? final String m = "hello \\ world"; ??????? System.out.println("Message is " + m); ??? } } When you run this as Java code using the "java" command, the output that gets printed is (as expected): Message is hello \ world Now, if I convert this Java code a jtreg test as follows (without any code change, just adding jtreg tags): /** ?* @test ?* @run main FooTest ?*/ public class FooTest { ??? public static void main(final String[] args) throws Exception { ??????? final String m = "hello \\ world"; ??????? System.out.println("Message is " + m); ??? } } Running it as a jtreg test, generates a report which has the System.out section that is: ----------System.out:(1/26)*---------- Message is hello \\ world Notice the unexpected additional backslash in that output. Is this intentional? In a non-trivial test case, that I was working on, it took me a (long) while to figure out that it was jtreg which was adding the additional backslash in the output and it wasn't my test case that had something wrong. For reference, jtreg -version gives: jtreg -version jtreg 6-dev+0 Installed in /jtreg/build/images/jtreg/lib/jtreg.jar Running on platform version 1.8.0_265 from /adoptopenjdk-8.jdk/Contents/Home/jre. Built with Java(TM) 2 SDK, Version 1.8.0_265-b01 on June 27, 2021. Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. JT Harness, version 6.0 ea b14 (June 27, 2021) JCov 3.0-2 Java Assembler Tools, version 7.0 ea b09 (June 27, 2021) TestNG (testng.jar): version 7.3.0 TestNG (jcommander.jar): version unknown TestNG (guice.jar): version 4.2.3 JUnit (junit.jar): version 4.13.2 JUnit (hamcrest.jar): version 2.2 -Jaikiran