Re: Why doesn’t jdk.internal.loader.Loader implement AutoCloseable?
Alan Bateman
Alan.Bateman at oracle.com
Sun May 26 08:31:55 UTC 2019
On 26/05/2019 06:45, Christian Stein wrote:
> Hi,
>
> following the documentation of ModulLayer [1] to create a
> temporary layer for testing, results in a FileSystemException
> when trying to delete the modular jar file after tests are finished.
Can you create a WeakReference to the module layer and do the cleanup
when the reference is queued? When a module layer is GC'ed then you
should find the JAR files containing modules will be closed and you can
delete them. As this is testing then maybe the test finish can null out
the reference to the module layer (and the class loaders if you have
references to those), call System.gc, and wait for the weak reference to
be cleaned.
That said, it might be time to change the Windows sharing mode that
JarFile/ZipFile uses to open JAR files. I'll create an issue for that.
-Alan
More information about the jigsaw-dev
mailing list