rt.jar put on a Proguard diet losses 26 MB
Michael Hall
mik3hall at gmail.com
Sat Dec 15 19:16:45 PST 2012
On Dec 15, 2012, at 4:08 PM, Jeff Palmer wrote:
> rt.jar went from 50,469 KB to 24,207 KB
The following would probably tell you if ProGuard is compressing on you despite the settings
> -dontshrink
> -dontobfuscate
If it doesn't compress and doesn't obfuscate I don't see how the decrease is possible.
import java.io.IOException;
import java.util.Date;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
public class JarList {
public static void main(String[] args) throws IOException {
int count = -1;
JarFile jf = new JarFile(args[0]);
if (args.length > 1)
count = new Integer(args[1]).intValue();
Enumeration e = jf.entries();
int curr = 0;
while (e.hasMoreElements()) {
if (count != -1) {
if (curr > count) break;
curr++;
}
JarEntry je = (JarEntry) e.nextElement();
String name = je.getName();
Date lastModified = new Date(je.getTime());
long uncompressedSize = je.getSize();
long compressedSize = je.getCompressedSize();
System.out.println("(" + uncompressedSize + "/" + compressedSize + ")\t" + lastModified + "\t" + name);
}
}
}
getting for example…
java JarList /Library/Java/JavaVirtualMachines/jdk1.7.0_10.jdk/Contents/Home/jre/lib/rt.jar 10
(0/0) Wed Nov 28 08:06:30 CST 2012 META-INF/
(2332/2332) Wed Nov 28 08:06:30 CST 2012 META-INF/MANIFEST.MF
(199/199) Wed Nov 28 08:00:00 CST 2012 WrapperGenerator$1.class
(7717/7717) Wed Nov 28 08:00:00 CST 2012 WrapperGenerator$AtomicType.class
(651/651) Wed Nov 28 08:00:00 CST 2012 WrapperGenerator$BaseType.class
(1695/1695) Wed Nov 28 08:00:00 CST 2012 WrapperGenerator$FunctionType.class
(3371/3371) Wed Nov 28 08:00:00 CST 2012 WrapperGenerator$StructType.class
(22150/22150) Wed Nov 28 08:00:00 CST 2012 WrapperGenerator.class
(6406/6406) Wed Nov 28 08:02:28 CST 2012 apple/applescript/AppleScriptEngine.class
(898/898) Wed Nov 28 08:02:28 CST 2012 apple/applescript/AppleScriptEngineFactory$1.class
(3495/3495) Wed Nov 28 08:02:28 CST 2012 apple/applescript/AppleScriptEngineFactory.class
Mine isn't compressed and isn't showing name obfuscation, which if you were real clever might get you what amounted to compression by just shortening the names as part of the obfuscation.
I've never used ProGuard but from what I've seen of zip files I don't know of any other fat you could trim for that kind of savings.
Michael Hall
trz nio.2 for OS X http://www195.pair.com/mik3hall/index.html#trz
HalfPipe Java 6/7 shell app http://www195.pair.com/mik3hall/index.html#halfpipe
AppConverter convert Apple jvm to openjdk apps http://www195.pair.com/mik3hall/index.html#appconverter
More information about the macosx-port-dev
mailing list