Moving Files Into JARs

August 27th, 2009

Moving files into jars reduces amount of seeks on startup, and has miscellaneous other performance/organization benefits. I added resource://gre-resources/ which maps to jar:toolkit.jar!/res/.

To move a file into a jar:

  1. Add a jar.mn entry.
  2. Remove existing references to the file in Makefile.in, packages-static files
  3. Add file to the removed-files.in list of dead files
  4. Update urls refering to the file in the source. Sometimes one has to switch from using file streams and filenames to using channels and URIs. This is the hard part.
  5. Set your bug as blocking bug 513027.

For an example see bug 508421.

2 Responses to “Moving Files Into JARs”

  1. skierpage Says:

    That jar: protocol is one of the many hidden gems of Firefox. You can browse a compressed slice of a website without unpacking it and with an about:config tweak you can view ZIP files in the browser!

    The Firefox implementation has got encoding and functionality bugs (#445065, #132008) but it’s still damn cool (#502528).

  2. Wladimir Palant Says:

    Unfortunately, extensions usually use the resource: protocol for JavaScript modules – but that feature explicitly requires physical files (https://bugzilla.mozilla.org/show_bug.cgi?id=406538).

Leave a Reply