Static executables
David Daney
ddaney@avtrex.com
Tue Jan 31 06:39:00 GMT 2006
Mohan Embar wrote:
>>Tom Tromey wrote:
>>>>>It would be helpful if someone wrote a page for the gcc wiki about
>>>static linking.
>>>>Like this:?
>>>>http://gcc.gnu.org/wiki/Statically%20linking%20libgcj
>>> I wish I had that reference awhile ago.
>> One variation on this:
>> object dummy = new fully.qualified.name.of.missing.Class();
>> is this:
>> Class dummy = fully.qualified.name.of.missing.class;
>> (i.e. private static final Class c1 = gnu.java.locale.Calendar.class)
>> This avoids creating a new instance, which may not always
> be possible.
If you are compiling from classfiles (pre 1.5) the .class construct will
not force a link (as it just does a Class.forName() or something like that).
But for compiling from .java source you are correct.
Also note that the dummy method is never run, it just forces the link to
happen.
If you have a tested example using the .class method, you could update
the Wiki.
David Daney.
More information about the Java
mailing list