Patch: Fix for PR 2369
Per Bothner
per@bothner.com
Fri Oct 12 09:12:00 GMT 2001
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
More information about the Java-patches
mailing list