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) {
....
}
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) {
....
}
- links to
-
Review openjdk/jdk/14025