module SimpleCov::SourceFile::SourceLoader

def ensure_remove_undefs(file_lines)

properly, so it has to be done here.
these options on `file.set_encoding` doesn't seem to work
nice to have and work around a JRuby incompatibility. Setting
invalid/undef replace are technically not really necessary but
def ensure_remove_undefs(file_lines)
  file_lines.each do |line|
    # simplecov:disable — defensive: only fires for non-UTF-8 source files
    line.encode!("UTF-8", invalid: :replace, undef: :replace) unless line.encoding == Encoding::UTF_8
    # simplecov:enable
  end
end