Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there something like bsdiff/Courgette for jar files?

Google uses bsdiff and Courgette for patching binary files like the Chrome distribution. Do any similar tools exist for patching jar files?

I am updating jar files remotely over a bandwidth-limited connection and would like to minimize the amount of data sent. I do have some control over the client machine to some extent (i.e. I can run scripts locally) and I am guaranteed that the target application will not be running at the time.

I know that I can patch java applications by putting updated class files in the classpath, but I would prefer a cleaner method for doing updates. It would be good if I could start with the target jar file, apply a binary patch, and then wind up with an updated jar file that is identical (bitwise) to the new jar (from which the patch was created).

like image 380
Ken Liu Avatar asked Mar 30 '10 15:03

Ken Liu


People also ask

What is Bsdiff?

Patch format used to update video game ROMs and produce patches for binary files; contains the differences that are to be applied to a source file in order to create a target file.

Can jar files be compared?

Jarcomp is a comparison tool for Jar files and Zip files. It's free and cross-platform. If you have two jar files or two zip files, it will show you what the differences are in the contents. It shows which files have been added, which have been removed, and which are present in both archives.


2 Answers

Try the javaxdelta project on Sourceforge. It should allow to create patches and to apply them.

[EDIT] This tool doesn't exist, yet. Open the JAR file with the usual tools and then use javaxdelta to create one patch per entry in the JAR. ZIP them up and copy them onto the server.

On the other side, you need to install a small executable JAR which takes the patch and the JAR file as arguments and applies the patch. You will have to write this one, too, but that shouldn't take much more than a few hours.

like image 53
Aaron Digulla Avatar answered Oct 06 '22 02:10

Aaron Digulla


.jar files are already compressed, so what you're really asking for is a compression that works well on zip files ;). If you get at it before you stuff it in the jar you have better odds of taking advantage of the knowledge that it is "java" I expect. I suspect you could adapt the factorization described in this paper as a java specific compression method.

like image 23
Logan Capaldo Avatar answered Oct 06 '22 01:10

Logan Capaldo