Closed shartte closed 9 months ago
What does it use that isn't JarURLConnection?
It's a bit peculiar. This is in a Minecraft Modding Context. The major modding framework uses some auto-modularization classloader which in turn uses custom URLConnection for retrieving resources from the jar files.
p.s.: I could probably implement URLConnection lastModified / contentLength for that particular URL connection, but even if I did, it doesn't seem like it would be used by Loader.
Well, the idea is to get that information from somewhere, yes. Why wouldn't it work?
The current code never sets the modification date of the file if it takes that codepath in Loader.
File.setLastModified() gets called, yes.
I'll try to get you a better error description, but when I had a breakpoint set at the location outlined above (where it throws the access denied error), it was recursively extracting an existing file.
It does set it here (In the JarUrlConnection branch) https://github.com/bytedeco/javacpp/blob/master/src/main/java/org/bytedeco/javacpp/Loader.java#L812
But it doesn't set it here: https://github.com/bytedeco/javacpp/blob/master/src/main/java/org/bytedeco/javacpp/Loader.java#L850
Although looking at the call-tree it does try to set it in the parent method.
But it doesn't set it here: https://github.com/bytedeco/javacpp/blob/master/src/main/java/org/bytedeco/javacpp/Loader.java#L850
No, because that information isn't available there. Where can we get that information in the case of your URLConnection?
But it doesn't set it here: https://github.com/bytedeco/javacpp/blob/master/src/main/java/org/bytedeco/javacpp/Loader.java#L850
No, because that information isn't available there. Where can we get that information in the case of your URLConnection?
Theoretically via
https://docs.oracle.com/javase/8/docs/api/java/net/URLConnection.html#getLastModified--
(While that method is not actually implemented for the custom URLConnection, I could do that).
Right, so please try to do that, yes.
Implementing getLastModified & getContentLength in the custom class-loader does indeed solve this problem.
This issue occurs because Loader tries to replace a DLL file that has already been extracted and loaded by another DLL, but only if the codepath for non-
JarURLConnection
based resources is taken.As far as I can tell, if the URL is a
JarURLConnection
, Loader will not try to delete&replace the File, if it already exists, has the same size and modification date. But if the URL is not aJarURLConnection
, it will always try to first delete, and then replace the file. See here: https://github.com/bytedeco/javacpp/blob/master/src/main/java/org/bytedeco/javacpp/Loader.java#L849This will not work, if different DLLs are loaded that use the same CRT. (i.e. avutil here loads, which will in turn try to load the javacpp basics).
Stacktrace: