7113349: Initial changeset for Macosx port to jdk
Reviewed-by: jjh, alanb, dholmes, anthony, ohrstrom, ksrini, jrose, weijun, smarks
Contributed-by: Alan Bateman <alan.bateman@oracle.com>, Alexander Potochkin <alexander.potochkin@oracle.com>, Alexander Zuev <alexander.zuev@oracle.com>, Andrew Brygin <andrew.brygin@oracle.com>, Artem Ananiev <artem.ananiev@oracle.com>, Alex Strange <astrange@apple.com>, Bino George <bino@apple.com>, Christine Lu <christine.lu@oracle.com>, David Katleman <david.katleman@oracle.com>, David Durrence <david_durrence@apple.com>, Dmitry Cherepanov <dmitry.cherepanov@oracle.com>, Greg Lewis <glewis@eyesbeyond.com>, Kevin Miller <kevin_m_miller@apple.com>, Kurt Miller <kurt@intricatesoftware.com>, Landon Fuller <landonf@plausiblelabs.com>, Leonid Romanov <leonid.romanov@oracle.com>, Loefty Walkowiak <loefty@apple.com>, Mark Reinhold <mark.reinhold@oracle.com>, Naoto Sato <naoto.sato@oracle.com>, Philip Race <philip.race@oracle.com>, Roger Hoover <rhoover@apple.com>, Scott Kovatch <scott.kovatch@oracle.com>, Sergey ByloKhov <sergey.bylokhov@oracle.com>, Mike Swingler <swingler@apple.com>, Tomas Hurka <tomas.hurka@oracle.com>
diff --git a/src/share/bin/java.c b/src/share/bin/java.c
index 2d88dc9..3133258 100644
--- a/src/share/bin/java.c
+++ b/src/share/bin/java.c
@@ -147,7 +147,6 @@
 static void GrowKnownVMs();
 static int  KnownVMIndex(const char* name);
 static void FreeKnownVMs();
-static void ShowSplashScreen();
 static jboolean IsWildCardEnabled();
 
 #define ARG_CHECK(n, f, a) if (n < 1) { \
@@ -165,25 +164,6 @@
 static jlong maxHeapSize        = 0;  /* max heap size */
 static jlong initialHeapSize    = 0;  /* inital heap size */
 
-int JNICALL JavaMain(void * args); /* entry point                  */
-
-enum LaunchMode {               // cf. sun.launcher.LauncherHelper
-    LM_UNKNOWN = 0,
-    LM_CLASS,
-    LM_JAR
-};
-
-static const char *launchModeNames[]
-    = { "Unknown", "Main class", "JAR file" };
-
-typedef struct {
-    int    argc;
-    char **argv;
-    int    mode;
-    char  *what;
-    InvocationFunctions ifn;
-} JavaMainArgs;
-
 /*
  * Entry point.
  */
@@ -210,6 +190,7 @@
     jlong start, end;
     char jvmpath[MAXPATHLEN];
     char jrepath[MAXPATHLEN];
+    char jvmcfg[MAXPATHLEN];
 
     _fVersion = fullversion;
     _dVersion = dotversion;
@@ -252,7 +233,8 @@
 
     CreateExecutionEnvironment(&argc, &argv,
                                jrepath, sizeof(jrepath),
-                               jvmpath, sizeof(jvmpath));
+                               jvmpath, sizeof(jvmpath),
+                               jvmcfg,  sizeof(jvmcfg));
 
     ifn.CreateJavaVM = 0;
     ifn.GetDefaultJavaVMInitArgs = 0;
@@ -312,11 +294,7 @@
     /* set the -Dsun.java.launcher.* platform properties */
     SetJavaLauncherPlatformProps();
 
-    /* Show the splash screen if needed */
-    ShowSplashScreen();
-
-    return ContinueInNewThread(&ifn, argc, argv, mode, what, ret);
-
+    return JVMInit(&ifn, threadStackSize, argc, argv, mode, what, ret);
 }
 /*
  * Always detach the main thread so that it appears to have ended when
@@ -375,6 +353,8 @@
     int ret = 0;
     jlong start, end;
 
+    RegisterThread();
+
     /* Initialize the virtual machine */
     start = CounterGet();
     if (!InitializeJVM(&vm, &env, &ifn)) {
@@ -444,7 +424,7 @@
      */
     mainClass = LoadMainClass(env, mode, what);
     CHECK_EXCEPTION_NULL_LEAVE(mainClass);
-
+    PostJVMInit(env, mainClass, vm);
     /*
      * The LoadMainClass not only loads the main class, it will also ensure
      * that the main method's signature is correct, therefore further checking
@@ -1067,7 +1047,9 @@
                    JLI_StrCmp(arg, "-jre-restrict-search") == 0 ||
                    JLI_StrCCmp(arg, "-splash:") == 0) {
             ; /* Ignore machine independent options already handled */
-        } else if (RemovableOption(arg) ) {
+        } else if (ProcessPlatformOption(arg)) {
+            ; /* Processing of platform dependent options */
+        } else if (RemovableOption(arg)) {
             ; /* Do not pass option to vm. */
         } else {
             AddOption(arg, NULL);
@@ -1129,17 +1111,6 @@
     return r == JNI_OK;
 }
 
-
-#define NULL_CHECK0(e) if ((e) == 0) { \
-    JLI_ReportErrorMessage(JNI_ERROR); \
-    return 0; \
-  }
-
-#define NULL_CHECK(e) if ((e) == 0) { \
-    JLI_ReportErrorMessage(JNI_ERROR); \
-    return; \
-  }
-
 static jclass helperClass = NULL;
 
 static jclass
@@ -1598,10 +1569,9 @@
  * mechanism.
  */
 jint
-ReadKnownVMs(const char *jrepath, const char * arch, jboolean speculative)
+ReadKnownVMs(const char *jvmCfgName, jboolean speculative)
 {
     FILE *jvmCfg;
-    char jvmCfgName[MAXPATHLEN+20];
     char line[MAXPATHLEN+20];
     int cnt = 0;
     int lineno = 0;
@@ -1614,8 +1584,6 @@
     if (JLI_IsTraceLauncher()) {
         start = CounterGet();
     }
-    JLI_Snprintf(jvmCfgName, sizeof(jvmCfgName), "%s%slib%s%s%sjvm.cfg",
-        jrepath, FILESEP, FILESEP, arch, FILESEP);
 
     jvmCfg = fopen(jvmCfgName, "r");
     if (jvmCfg == NULL) {
@@ -1775,7 +1743,7 @@
  * Displays the splash screen according to the jar file name
  * and image file names stored in environment variables
  */
-static void
+void
 ShowSplashScreen()
 {
     const char *jar_name = getenv(SPLASH_JAR_ENV_ENTRY);
@@ -1852,8 +1820,9 @@
     return _wc_enabled;
 }
 
-static int
-ContinueInNewThread(InvocationFunctions* ifn, int argc, char **argv,
+int
+ContinueInNewThread(InvocationFunctions* ifn, jlong threadStackSize,
+                    int argc, char **argv,
                     int mode, char *what, int ret)
 {