void () { String in = """ enum Color { RED, GREEN, BLUE } interface X { void x(); } @interface Anno {} record R(int i, int j) {} """; String what = "class 'X {}"; String by = "/** @author me */\n" + "class $X$ {}"; String expected = """ /** @author me */ enum Color { RED, GREEN, BLUE } /** @author me */ interface X { void x(); } /** @author me */ @interface Anno {} /** @author me */ record R(int i, int j) {} """; assertEquals("Special class replacement", expected, replace(in, what, by, true)); String in2 = """ new ArrayList<String>(null) { @Override public int hashCode() { return super.hashCode(); } }"""; String by2 = """ class $X$ { public String toString() { return "hello"; } } """; String expected2 = """ new ArrayList<String>(null){ public String toString() { return "hello"; } @Override public int hashCode() { return super.hashCode(); } }"""; assertEquals("Special anonymous class replacement", expected2, replace(in2, what, by2, false)); assertTrue(true); }