imagej / imagej-ui-swing

ImageJ UI for Java Swing.
BSD 2-Clause "Simplified" License
10 stars 20 forks source link

Remove workaround to overwriting jars #50

Closed hinerm closed 3 months ago

hinerm commented 9 years ago

Currently the updater puts jars in a temporary directory that is consolidated by the launcher on launching. This is primarily to work around the aggressive .jar locking by Windows.

Java 7 introduced the URLClassLoader.close method, which will free up any jars loaded by the ClassLoader for deletion/overwriting.

This will require careful consideration of ClassLoader hierarchy but will allow for a simpler launcher. It would be good to combine with compile and run work as well, as that could also involve ClassLoader restructuring.

hinerm commented 9 years ago

MCVE for testing this: https://gist.github.com/hinerm/5721562ade5562d8599b

hinerm commented 9 years ago

To test: what happens with the system classloader? (that is, confirm we understand how ImageJ 1 is able to rewrite itself..)

hinerm commented 9 years ago

MCVE for a jar loaded by the system class loader to overwrite itself: https://gist.github.com/hinerm/ac02be7beacaa1a065b3

A jar with this main class is able to overwrite itself on windows.

ctrueden commented 3 months ago

We are switching the Fiji launcher to a new one we made called Jaunch. Jaunch does include the same logic for stashing updates in a special update folder. This is more robust than assuming your running Java program will always let go of file locks on Windows. It's fine; it works. :smile: