Re: Enhancement request
On Thu, 4 Sep 2008, Wayne wrote:
Tom Anderson wrote:
On Wed, 3 Sep 2008, Lionel van den Berg wrote:
On Sep 4, 2:31 pm, Tegiri Nenashi <TegiriNena...@gmail.com> wrote:
I'm programming java since 96 and can't remember myself ever using
main method with arguments. Does anybody have a different experience?
I've used them, mainly when running from commandline.
Same here. I've used them a lot.
Now that I don't use these arguments, I never feel to make a
concentrated effort to remember them. Why bother remembering something
that I can easily copy over from somewhere else. However, after doingg
this same trick for 100 time, I ask why Java can't just be simplified
to allow
static void main() {
}
as a program entry point?
Considering you ownly write one main method for an application it is
hardly a common inconvenience, I therefore see no real reason to
support your suggestion.
Agreed.
What i would support would be an int return type from main, so you can
return an exit code to the OS. I don't see why one should have to use
System.exit to do that.
Because from the OS point of view the running program is
the JVM, nor your Java masterpiece.
Right, which is why the JVM needs to provide a mechanism to bridge the
two.
There is no way to return an exit status without shutting down the JVM.
That's certainly true. And, as you mention below, in the presence of a
GUI, or threads, main can return before the app quits. I don't see why
that's a showstopper - when main returns, the return value gets stashed,
and when the process exits, it gets used as the exit status. That might be
immediately, or it might be an arbitrary amount of time later. You would
need a policy about what happens if another thread does System.exit()
after main has returned - i'd suggest it overrides the returned status
code. None of that seems complicated.
Instead of an exit status integer, consider a more sophisticated
strategy, such as logging, writing a status to a file or socket, etc.
There are times when those are useful, but there are also times when an
exit status is what you need. If you want to write a mail filter to use
with procmail, for instance, or anything you want to integrate with shell
scripting.
tom
--
Gin makes a man mean; let's booze up and riot!