_Jv_ThisExecutable

Per Bothner per@bothner.com
Mon Dec 2 23:40:00 GMT 2002


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/



More information about the Java mailing list