What is the smallest, simplest way to reproduce the problem?
class A {
void foo(String bar) {
return """
\\n
""".formatted(bar);
}
}
What did you expect to see?
the code remaining as is.
What did you see instead?
class A {
void foo(String bar) {
return """
\%n
""".formatted(bar);
}
}
That's an invalid escape sequence. Root cause of the bug is the recipe replacing \n without ever checking if that's part of \\n.
Be aware that even though the test looks like it contains the double backslash in the test code, it doesn't. The text block contains double backslash, but that only generates the Java test input, which contains a single backslash.
What is the smallest, simplest way to reproduce the problem?
What did you expect to see?
the code remaining as is.
What did you see instead?
That's an invalid escape sequence. Root cause of the bug is the recipe replacing
\n
without ever checking if that's part of\\n
.Be aware that even though the test looks like it contains the double backslash in the test code, it doesn't. The text block contains double backslash, but that only generates the Java test input, which contains a single backslash.
Are you interested in contributing a fix to OpenRewrite?
Yes. But too tired to look into that now.