[java] [cs] manually follow in replace_mono to avoid infinite recursion (see #3024)