<div dir="ltr"><br><div>For the interested, here's a diff of classes loaded before and after the removal of the NIO dependency:</div><div><br></div><div>33a34<br>> java.io.UnixFileSystem$UnixFileKey<br>140,142d140<br>< java.lang.ThreadLocal<br>< java.lang.ThreadLocal$ThreadLocalMap<br>< java.lang.ThreadLocal$ThreadLocalMap$Entry<br>242,256d239<br>< java.nio.file.CopyOption<br>< java.nio.file.FileSystem<br>< java.nio.file.Files<br>< java.nio.file.LinkOption<br>< java.nio.file.OpenOption<br>< java.nio.file.Path<br>< java.nio.file.StandardOpenOption<br>< java.nio.file.Watchable<br>< java.nio.file.attribute.AttributeView<br>< java.nio.file.attribute.BasicFileAttributeView<br>< java.nio.file.attribute.BasicFileAttributes<br>< java.nio.file.attribute.FileAttributeView<br>< java.nio.file.attribute.FileTime<br>< java.nio.file.attribute.PosixFileAttributes<br>< java.nio.file.spi.FileSystemProvider<br>296,299d278<br>< java.util.IdentityHashMap<br>< java.util.IdentityHashMap$IdentityHashMapIterator<br>< java.util.IdentityHashMap$KeyIterator<br>< java.util.IdentityHashMap$KeySet<br>348d326<br>< java.util.concurrent.TimeUnit<br>438d415<br>< jdk.internal.misc.CarrierThreadLocal<br>446,447d422<br>< jdk.internal.misc.TerminatingThreadLocal<br>< jdk.internal.misc.TerminatingThreadLocal$1<br>547,571d521<br>< sun.nio.fs.AbstractBasicFileAttributeView<br>< sun.nio.fs.AbstractFileSystemProvider<br>< sun.nio.fs.BsdFileAttributeViews<br>< sun.nio.fs.BsdFileAttributeViews$Basic<br>< sun.nio.fs.BsdFileSystem<br>< sun.nio.fs.BsdFileSystemProvider<br>< sun.nio.fs.DefaultFileSystemProvider<br>< sun.nio.fs.DynamicFileAttributeView<br>< sun.nio.fs.MacOSXFileSystem<br>< sun.nio.fs.MacOSXFileSystemProvider<br>< sun.nio.fs.NativeBuffer<br>< sun.nio.fs.NativeBuffer$Deallocator<br>< sun.nio.fs.NativeBuffers<br>< sun.nio.fs.NativeBuffers$1<br>< sun.nio.fs.UnixFileAttributeViews$Basic<br>< sun.nio.fs.UnixFileAttributes<br>< sun.nio.fs.UnixFileAttributes$UnixAsBasicFileAttributes<br>< sun.nio.fs.UnixFileKey<br>< sun.nio.fs.UnixFileStoreAttributes<br>< sun.nio.fs.UnixFileSystem<br>< sun.nio.fs.UnixFileSystemProvider<br>< sun.nio.fs.UnixMountEntry<br>< sun.nio.fs.UnixNativeDispatcher<br>< sun.nio.fs.UnixPath<br>< sun.nio.fs.Util<br></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Mon, Jan 26, 2026 at 4:36 PM Eirik Bjørsnøs <<a href="mailto:eirbjo@gmail.com">eirbjo@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi,</div><div><br></div><div>Where available, ZipFile.Source.Key uses the "file key" from BasicAttributes:fileKey to determine if paths refer to the same file instance.</div><div><br></div><div>For a "hello world" program in a jar on the classpath, this dependency on the NIO file system API pulls in just about 50 classes. (See diff below).</div><div><br></div><div>If we rewrite ZipFile to not consider the file key and to use File::lastModified instead of BasicFileAttributes::lastModifiedTime, these classes are no longer loaded.</div><div><br></div><div>The loading of 50 extra classes (comprising 9 percent of 576 classes) seems like a high price to pay for this caching mechanism!</div><div><br></div><div>As an experiment, I added File::fileKey which on Unix calls stat and retrieves the device and inode information in similar fashion to what NIO's BasicFileAttributes::fileKey does. This allows us to still consider the same "file key" information as today, but without loading these 50 extra classes.</div><div><br></div><div>Perhaps we should consider adding File::fileKey as a public class? If not, perhaps we can keep it private and expose it internally through a shared secret?</div><div><br></div><div>See the draft implementation/experiment in this branch:</div><div><br></div><div><a href="https://github.com/openjdk/jdk/compare/master...eirbjo:zipfile-java.io-filekey?expand=1" target="_blank">https://github.com/openjdk/jdk/compare/master...eirbjo:zipfile-java.io-filekey?expand=1</a></div><div><br></div><div>Thoughts and opinions are welcome.</div><div><br></div><div>Eirik. </div><div><br></div><div><br></div></div>
</blockquote></div>