HotSpot has a few cases where information is parsed from a file, or from a memory buffer, one line at a time. Example:
https://github.com/openjdk/jdk/blob/064628471b83616b4463baa78618d1b7a66d0c7c/src/hotspot/share/cds/classListParser.cpp#L169
https://github.com/openjdk/jdk/blob/064628471b83616b4463baa78618d1b7a66d0c7c/src/hotspot/share/compiler/compilerOracle.cpp#L1059-L1068
Common problems:
- They use a fixed buffer for reading a line, so long (but valid) lines will cause errors.
- There's ad-hoc code that deals with FILE* differently than from memory.
This RFE implements a common utility (inputStream) for reading lines from files and memory buffers (see FileInput and MemoryInput in the PR). We fixed only classListParser and compilerOracle in this RFE, but we can fix other readers in follow-up RFEs.
The API allows other source of input to be implemented. For example, one could implement a SocketInput if there's a use case for it.
In the future, inputStream can be extended (or encapsulated in a higher-level reader class) to read typed input tokens (for example, integers, strings, etc.
Credit
The inputStream class and friends are contributed by [~jrose]. See https://mail.openjdk.org/pipermail/hotspot-dev/2024-April/087077.html
https://github.com/openjdk/jdk/blob/064628471b83616b4463baa78618d1b7a66d0c7c/src/hotspot/share/cds/classListParser.cpp#L169
https://github.com/openjdk/jdk/blob/064628471b83616b4463baa78618d1b7a66d0c7c/src/hotspot/share/compiler/compilerOracle.cpp#L1059-L1068
Common problems:
- They use a fixed buffer for reading a line, so long (but valid) lines will cause errors.
- There's ad-hoc code that deals with FILE* differently than from memory.
This RFE implements a common utility (inputStream) for reading lines from files and memory buffers (see FileInput and MemoryInput in the PR). We fixed only classListParser and compilerOracle in this RFE, but we can fix other readers in follow-up RFEs.
The API allows other source of input to be implemented. For example, one could implement a SocketInput if there's a use case for it.
In the future, inputStream can be extended (or encapsulated in a higher-level reader class) to read typed input tokens (for example, integers, strings, etc.
Credit
The inputStream class and friends are contributed by [~jrose]. See https://mail.openjdk.org/pipermail/hotspot-dev/2024-April/087077.html
- duplicates
-
JDK-8329728 Read long lines in ClassListParser
- Closed
- relates to
-
JDK-8332120 Potential compilation failure in istream.cpp:205 - loss of data on conversion
- Resolved