Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8308252

Refactor line-by-line file reading code

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 21
    • hotspot

      Both classListParser.cpp and ciReplay.cpp need to read from a file line-by-line

      https://github.com/openjdk/jdk/blob/2f1c65486b1e584f9c4a2eb7af2414d032a02748/src/hotspot/share/cds/classListParser.cpp#L168

      https://github.com/openjdk/jdk/blob/2f1c65486b1e584f9c4a2eb7af2414d032a02748/src/hotspot/share/ci/ciReplay.cpp#L607-L630

      The former uses a fixed buffer, so it cannot handle very long lines. The latter uses a growable buffer, but the logic is a bit complicated.

      We should create a common class for reading files with arbitrarily long lines. The API is:

      LineReader reader("filename.txt");
      char* line;
      while ((line = reader.get_line()) != nullptr) {
          ....
      }

            igraves Ian Graves
            iklam Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: