RFR: 8329728: Read arbitrarily long lines in ClassListParser

Calvin Cheung ccheung at openjdk.org
Mon Apr 8 22:10:09 UTC 2024


On Mon, 8 Apr 2024 04:51:31 GMT, Ioi Lam <iklam at openjdk.org> wrote:

> Today the `ClassListParser` has a hard-coded limit of 4096 chars for each line in the CDS class list file. However, it's possible for a line to be much longer than than (64KB for the class name, plus extra information that can include path names, IDs, etc).
> 
> I wrote a utility class `LineReader` that automatically allocates a buffer before calling `fgets()`. Hopefully this can be useful for other cases where we call `fgets()` with a fixed buffer size.

src/hotspot/share/utilities/lineReader.cpp line 44:

> 42: void LineReader::init(FILE* file) {
> 43:   _file = file;
> 44:   _buffer_len = 16; // start at small size to test expansion logic

Maybe set the `_buffer_len` to a larger value (256?) for non-debug build?

src/hotspot/share/utilities/lineReader.hpp line 48:

> 46:   }
> 47: 
> 48:   // Return one line from _file, as a NUL-terminated string. The length and contents of this

Suggestion: NUL-terminated -> null-terminated

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/18669#discussion_r1556473848
PR Review Comment: https://git.openjdk.org/jdk/pull/18669#discussion_r1556475659


More information about the hotspot-dev mailing list