> The only surprise is that it doesn't close as it shouldn't need the
> file descriptor after it mmapped.

Indeed, both on Windows and Unix file descriptor can be closed after mapping.

On the other hand, ImageFileReader is not prepared for that.

See http://hg.openjdk.java.net/jdk/jdk/file/8bdf2b5f472d/src/java.base/share/native/libjimage/imageFile.cpp

ImageFileReader::get_resource() uses ImageFileReader::read_at() if resource is not compressed.

Furthermore, ImageFileReader::get_resource() uses ImageFileReader::read_at() if not entire jimage is mapped. This happens if architecture is not 64-bit.

Even if these code paths are changed, I still think that closing file descriptor can be unexpected and will provoke future bugs.

Reply via email to