Static executables

Tom Tromey tromey@redhat.com
Mon Jan 30 21:21:00 GMT 2006


>>>>> "Per" == Per Bothner <per@bothner.com> writes:

>>> Any code that uses reflection will not work properly.  This is a
>>> problem because parts of the core class library depend on reflection.
>>> For instance, character set translators and locales are loaded this
>>> way.

Per> That may be somewhat misleading.  It's not reflection per se that is
Per> the problem, but dynamicaly loading classes.

Yeah, sorry about that...
Andrzej, listen to Per :-)

Per>    static final Class myclass1 = mypackage.MyClass1.class;

Per> I don't guarantee that this will actually work - but it is something
Per> that probably *should* work, and shouldn't be very difficult to make
Per> work if it doesn't.

Yes, I think this does work.  We actually use this in libgcj itself
to link in certain files, to make at least some minimal functionality
work when linked statically.

This problem will probably get a bit worse when we change the locales
to be property files instead of classes.  Right now I don't think
there is any way to ensure that a compiled resource file is actually
linked in :-(

Actually, maybe linking with --whole-archive would help.  Of course
this also loses one of the benefits of static linking, namely removing
the parts you don't need.

Tom



More information about the Java mailing list