This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: _Jv_ThisExecutable
- From: Per Bothner <per at bothner dot com>
- To: tromey at redhat dot com
- Cc: gcj mail list <java at gcc dot gnu dot org>, Per Bothner <bothner at bothner dot com>
- Date: Mon, 02 Dec 2002 23:28:59 -0800
- Subject: Re: _Jv_ThisExecutable
- References: <87fztfycc9.fsf@fleche.redhat.com>
Tom Tromey wrote:
One fix would be not to crash if `this executable' isn't set -- either
we could set it to a dummy value or we could just add conditions.
Another fix would be to add JvThisExecutable and require it to be
called.
I don't like that - it doesn't seem like this is worth changing the
API for.
Another would be to add a new argument to _Jv_CreateJavaVM.
Likewise.
Any preferences? Per, I thought you might prefer one approach over
another, since you wrote the CNI invocation API.
I don't know how gnu.gcj.progname is used, and whether one might
want to allow use of _Jv_ThisExecutable(char*) to change the default.
I suggest:
In natRuntime.cc:
char *executable = Jv_ThisExecutable();
#ifdef HAVE_PROC_SELF_EXE
if (! executable)
{
char exec_name[20];
sprintf (exec_name, "/proc/%d/exe", getpid ());
_Jv_ThisExecutable (executable = exec_name);
}
#else
if (executable)
#endif
// The name used to invoke this process (argv[0] in C).
SET ("gnu.gcj.progname", executable);
in prims.cc:
Jv_RunMain (jclass klass, const char *name, int argc, const char **argv,
bool is_jar)
{
_Jv_argv = argv;
_Jv_argc = argc;
java::lang::Runtime *runtime = NULL;
#ifdef DISABLE_MAIN_ARGS
if (! _Jv_execName)
_Jv_ThisExecutable ("[Embedded App]");
#else
#ifndef HAVE_PROC_SELF_EXE
if (! _Jv_execName)
_Jv_ThisExecutable (argv[0]);
#endif /* ! HAVE_PROC_SELF_EXE */
#endif /* DISABLE_MAIN_ARGS */
--
--Per Bothner
per@bothner.com http://www.bothner.com/per/