RFR: 8308753: Class-File API transition to Preview [v24]

Chen Liang liach at openjdk.org
Thu Nov 9 00:23:15 UTC 2023


On Wed, 8 Nov 2023 15:45:56 GMT, Konrad Windszus <duke at openjdk.org> wrote:

> I know, but for memory consumption reasons everyone should prefer just passing an InputStream. Is the memory consumption with `ClassFile.of().parse(Path)` any better (i.e. are you using a `java.io.RandomAccessFile` or `java.nio.channels.SeekableByteChannel` under the hood)? I think that deserves a sentence in the javadoc.

FYI `parse(Path)` is just a shortcut to read all bytes from a file, like `parse(Files.readAllBytes(path))`. Classfile implementation fetches the byte array very often (constant pool reading, lazy expansion) so keeping the bytes in a in-memory array is better.

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

PR Comment: https://git.openjdk.org/jdk/pull/15706#issuecomment-1802967277


More information about the build-dev mailing list