RFR: 8329728: Read arbitrarily long lines in ClassListParser

John Rose john.r.rose at oracle.com
Sun Apr 14 07:34:39 UTC 2024


I have been developing something on the back burner for robust
text input.  I got tired of looking at fixed-sized buffers for
the compiler oracle and CDS, and now that CDS is scaling up
in its demands for complex configuration files, I agree we
need something better.

Here’s my draft work:
  https://github.com/openjdk/jdk/pull/18773

Please consider adopting it as a foundation for better CDS
configuration reading.  It’s old work, based to the repo
as of about a year ago.  But it should rebase easily.

Thanks,
— John

P.S. As a next layer I’d like to make something like sscanf,
except that it operates on the inputStream, like print_cr
does formatted output on outputStream, but in the reverse
direction.  But for starters we need a solid foundation
for flexible line-oriented input.


On 7 Apr 2024, at 21:56, Ioi Lam 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.
>
> -------------
>
> Commit messages:
>  - 8329728: Read arbitrarily long lines in ClassListParser
>
> Changes: https://git.openjdk.org/jdk/pull/18669/files
>   Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=18669&range=00
>   Issue: https://bugs.openjdk.org/browse/JDK-8329728
>   Stats: 235 lines in 5 files changed: 193 ins; 18 del; 24 mod
>   Patch: https://git.openjdk.org/jdk/pull/18669.diff
>   Fetch: git fetch https://git.openjdk.org/jdk.git pull/18669/head:pull/18669
>
> PR: https://git.openjdk.org/jdk/pull/18669


More information about the hotspot-dev mailing list