addr2line and the name of the executable
Andrew Haley
aph@redhat.com
Wed Feb 19 14:58:00 GMT 2003
Ranjit Mathew writes:
> > > So the property "gnu.gcj.progname" would not really be "the name by
> > > which the program was invoked" - isn't that (sort of) wrong?
> >
> >The comment only says "similar to". It depends on what you want the
> >information for. If you really want the file, that's just what you
> >need.
>
> Most of the uses for argv[0] that I've seen are typically like:
> ...
> if( argc < 2)
> {
> printf( "Usage: %s <whatever>\n", argv[0]);
> exit( 1);
> }
>
> In "normal" Java programs, this is replaced by
> "Usage: java FooBar <whatever>" since this used to be the only
> way to invoke a Java program. However, with a natively
> compiled Java program, one cannot assume this and needs
> access to something like argv[0]
You don't _need_ it. It's only useful if someone does something
wicked, such as giving an executable a different name from the class
that provides the implementation. Java does not allow this, and that
it a _very_ good thing.
> - this was the whole
> point of my asking for, what became the "gnu.gcj.progname"
> property. See this thread for the background:
>
> http://gcc.gnu.org/ml/java/2002-10/threads.html#00149
>
> It is in this light that I consider the current
> implementation to be in error.
I see.
> If we need the actual path to the executable, this is best
> served by something like _Jv_platform_getexecutable( ) as
> Mohan's patch suggests.
Okay.
Andrew.
More information about the Java
mailing list