aboutsummaryrefslogtreecommitdiff
path: root/libjava/prims.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/prims.cc')
-rw-r--r--libjava/prims.cc59
1 files changed, 25 insertions, 34 deletions
diff --git a/libjava/prims.cc b/libjava/prims.cc
index 2195db161e1..7e66bc767b0 100644
--- a/libjava/prims.cc
+++ b/libjava/prims.cc
@@ -86,13 +86,34 @@ const char *_Jv_Jar_Class_Path;
property_pair *_Jv_Environment_Properties;
#endif
-// The name of this executable.
-static char *_Jv_execName;
-
// Stash the argv pointer to benefit native libraries that need it.
const char **_Jv_argv;
int _Jv_argc;
+// Argument support.
+int
+_Jv_GetNbArgs (void)
+{
+ // _Jv_argc is 0 if not explicitly initialized.
+ return _Jv_argc;
+}
+
+const char *
+_Jv_GetSafeArg (int index)
+{
+ if (index >=0 && index < _Jv_GetNbArgs ())
+ return _Jv_argv[index];
+ else
+ return "";
+}
+
+void
+_Jv_SetArgs (int argc, const char **argv)
+{
+ _Jv_argc = argc;
+ _Jv_argv = argv;
+}
+
#ifdef ENABLE_JVMPI
// Pointer to JVMPI notification functions.
void (*_Jv_JVMPI_Notify_OBJECT_ALLOC) (JVMPI_Event *event);
@@ -707,22 +728,6 @@ static JArray<jstring> *arg_vec;
// The primary thread.
static java::lang::Thread *main_thread;
-char *
-_Jv_ThisExecutable (void)
-{
- return _Jv_execName;
-}
-
-void
-_Jv_ThisExecutable (const char *name)
-{
- if (name)
- {
- _Jv_execName = (char *) _Jv_Malloc (strlen (name) + 1);
- strcpy (_Jv_execName, name);
- }
-}
-
#ifndef DISABLE_GETENV_PROPERTIES
static char *
@@ -955,24 +960,10 @@ void
_Jv_RunMain (jclass klass, const char *name, int argc, const char **argv,
bool is_jar)
{
- _Jv_argv = argv;
- _Jv_argc = argc;
+ _Jv_SetArgs (argc, argv);
java::lang::Runtime *runtime = NULL;
-
-#ifdef DISABLE_MAIN_ARGS
- _Jv_ThisExecutable ("[Embedded App]");
-#else
-#ifdef HAVE_PROC_SELF_EXE
- char exec_name[20];
- sprintf (exec_name, "/proc/%d/exe", getpid ());
- _Jv_ThisExecutable (exec_name);
-#else
- _Jv_ThisExecutable (argv[0]);
-#endif /* HAVE_PROC_SELF_EXE */
-#endif /* DISABLE_MAIN_ARGS */
-
try
{
// Set this very early so that it is seen when java.lang.System