This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch: Fix for PR 2369


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]