This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch: Fix for PR 2369
- From: Per Bothner <per at bothner dot com>
- To: Bryce McKinlay <bryce at waitaki dot otago dot ac dot nz>
- Cc: tromey at redhat dot com, Java Patch List <java-patches at gcc dot gnu dot org>, Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 25 Nov 2001 16:42:35 -0800
- Subject: Re: Patch: Fix for PR 2369
- References: <87r8qm8vaj.fsf@creche.redhat.com> <3C018B8F.2020108@waitaki.otago.ac.nz>
Bryce McKinlay wrote:
> If we passed the --main option through to jc1, it could verify that it
> is not only a valid class name but also an actual class that contains
> a "main" method. Since jc1 is always run before the linker, it could
> give an intelligent error message if --main wasn't valid. This
> wouldn't help when just using "gcj" for linking, though.
That would make us different from javac, which allows many classes to have
a 'main' methods, and where which one is chosen is done at run-time, rather
than compilation time. In our case we pick link time to choose the desired
main.
This is mainly an issue when compiling a whole bunch of classes into a .so,
and where the .so has multiple entry points.
> It would also be nice if gcj would automatically find a "main" when
no --main option is given.
I agree. But it is a non-trivial. You might be linking in a C/C++
driver that contains a 'main' (and uses the invocation interface).
I could see: If no --main is specified, and there is no 'main'
(C-style) entry-point, look for Java main methods. It could look
for the first match, or it could require there only be a single match,
but give preference to non-libraries.
--Per