Binary size of statically linked java application
Andrew Haley
aph@redhat.com
Mon Nov 27 17:22:00 GMT 2006
Marco Trudel writes:
> Mohan Embar wrote:
> > Hi All,
> >
> >> I usually remove AWT/Swing (the whole GUI stuff) and the whole
> >> javax.crypto stuff. Then a real application is about 4.5mb (stripped of
> >> course).
> >
> > I'm not clear on why this would work given that the linker is supposed
> > to strip out unused code.
>
> Well, I'm not talking about objects that won't be pulled into the final
> binary (as you said, that wouldn't make sense). I'm talking about the
> ones that will but are actually not really needed... From my FAQ:
>
> Why are the binaries so big? With GCJ X.Y.Z, they were way smaller...
> As GCJ evolves, it supports more and more classes of the Java API. The
> problem now is, that the Java API classes are heavily interconnected; a
> simple "Hello World" application uses the security manager which uses
> AWT which uses... Because of this, you will always have a big part of
> the GCJ library in your binaries.
> For Java, this is not a problem. Endusers require to have the JVM, thus
> having all classes anyway. For GCJ, this is a bigger problem because
> it's not just a bug that can be fixed. The design of Java doesn't fit
> into the concept of native compilation (concerning the size of binaries).
Eh? Sure it does. With the classical Java virtual machine you have a
bunch of libraries in .jar files, and with gcj you have a bunch of
libraries in DSOs. Same thing, more or less: the DSOs are
precompiled, the .jar files aren't.
Andrew.
More information about the Java
mailing list