harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r447408 - /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/launcher/shared/main.c
Date Mon, 18 Sep 2006 14:17:50 GMT
Author: geirm
Date: Mon Sep 18 07:17:49 2006
New Revision: 447408

URL: http://svn.apache.org/viewvc?view=rev&rev=447408
Log:
Small tweaks to make this work with DRLVM for running jars.

1) modified CreateVMArgs to take the "mainClassJar" variable  
   as a handle so that CreateVMArgs could actually set it if
   JarRunner wasn't found in vm properties

2) line 671 - commented out CallStaticObjectMethod() as it 
   doesn't seem to do anything other than test that the 
   class is present.  It's not even clear why this should work
   because I didn't think that jar was on the classpath.  
   Anyway, the real pain is that it crashes DRLVM so that's something
   we need to hunt down, and as it's just a safety check
   J9 on linux (Ubuntu 6) still works


Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/launcher/shared/main.c

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/launcher/shared/main.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/launcher/shared/main.c?view=diff&rev=447408&r1=447407&r2=447408
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/launcher/shared/main.c
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/launcher/shared/main.c
Mon Sep 18 07:17:49 2006
@@ -36,6 +36,8 @@
 #define HY_TOOLS_PATH "tools.jar"
 #define HY_TOOLS_PROP "-Dorg.apache.harmony.tool=true"
 
+#define HARMONY_JARRUNNER_CLASSNAME  "org.apache.harmony.vm.JarRunner"
+
 #if defined(WIN32)
 #define PLATFORM_STRNICMP strnicmp
 #endif
@@ -56,7 +58,7 @@
             jint (JNICALL ** CreateJavaVM) (JavaVM **, JNIEnv **,
                                             JavaVMInitArgs *),
             int isJvmSubDir, UDATA classArg, char *propertiesFileName,
-            int isStandaloneJar, char *mainClassJar, char *vmdllsubdir));
+            int isStandaloneJar, char **mainClassJar, char *vmdllsubdir));
 char *VMCALL vmdll_parseCmdLine
 PROTOTYPE ((HyPortLibrary * portLibrary, UDATA lastLegalArg, char **argv));
 char *VMCALL vmdlldir_parseCmdLine
@@ -602,20 +604,14 @@
   jint (JNICALL * CreateJavaVM) (JavaVM **, JNIEnv **, JavaVMInitArgs *);
   PORT_ACCESS_FROM_PORT (portLibrary);
 
-  mainClassJar = hymem_allocate_memory (50);
-  if (mainClassJar == NULL)
-    {
-      /* HYNLS_EXELIB_INTERNAL_VM_ERR_OUT_OF_MEMORY=Internal VM error: Out of memory\n */
-      PORTLIB->nls_printf (PORTLIB, HYNLS_ERROR,
-                           HYNLS_EXELIB_INTERNAL_VM_ERR_OUT_OF_MEMORY);
-      return 1;
-    }
-  if (createVMArgs
-      (portLibrary, argc, argv, handle, version, ignoreUnrecognized, &vm_args,
-       &CreateJavaVM, isJvmSubDir, classArg, propertiesFileName,
-       isStandaloneJar, mainClassJar, vmdllsubdir))
-    return 1;
-
+  mainClassJar = NULL;
+  
+  if (createVMArgs(portLibrary, argc, argv, handle, version, ignoreUnrecognized, &vm_args,
+                        &CreateJavaVM, isJvmSubDir, classArg, propertiesFileName,
+                        isStandaloneJar, &mainClassJar, vmdllsubdir)) {
+     return 1;
+   }
+       
   if (CreateJavaVM (&jvm, &env, &vm_args))
     {
       /* HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_JAVA_VM=Internal VM error\: Failed to
create Java VM\n */
@@ -637,6 +633,7 @@
           mainClass = mainClassJar;
 
           jStrObject = (*env)->NewStringUTF (env, mainClass);
+          
           if (!jStrObject)
             {
               (*env)->ExceptionDescribe (env);
@@ -665,14 +662,23 @@
               //goto cleanup;
             }
 
-          /* should not spawn an exception */
-          jarRunner =
+          /* ensure that the jar is the first arg passed to the jar runner */
+          
+          classArg--;
+
+            
+/*
+     $$$ GMJ - removed this as it causes DRLVM to crash.  Need to fix
+        DRLVM, but also have no idea why this is important - just seems
+        to be a test
+    
+    jarRunner =
             (*env)->CallStaticObjectMethod (env, clazz, mID, jStrObject);
 
           if (jarRunner)
             {
               (*env)->DeleteLocalRef (env, jarRunner);
-              classArg -= 1;    /* make sure that the JAR is the first argument */
+              classArg -= 1;    // make sure that the JAR is the first argument 
             }
           else
             {
@@ -681,6 +687,7 @@
               rc = 3;
               //goto cleanup;
             }
+            */
         }
 
       javaRc =
@@ -734,7 +741,7 @@
               jint (JNICALL ** CreateJavaVM) (JavaVM **, JNIEnv **,
                                               JavaVMInitArgs *),
               int isJvmSubDir, UDATA classArg, char *propertiesFileName,
-              int isStandaloneJar, char *mainClassJar, char *vmdllsubdir)
+              int isStandaloneJar, char **mainClassJar, char *vmdllsubdir)
 {
   JavaVMOption *options;
   char *exeName;
@@ -790,7 +797,9 @@
             {
               if (strncmp (startOfLine, "jarMainClass", 12) == 0)
                 {
-                  strcpy (mainClassJar, startOfLine + 13);
+                  *mainClassJar = hymem_allocate_memory (strlen(startOfLine + 13) + 1);
+                    
+                  strcpy (*mainClassJar, startOfLine + 13);
                   useDefaultJarRunner = 1;
                 }
             }
@@ -851,19 +860,20 @@
           //printf ("expandedLineStr[l] = %s\n", expandedLineStr[l]);
         }
     }
+    
   if (isStandaloneJar)
     {
       if (useDefaultJarRunner == 0)
         {
-          mainClassJar = hymem_allocate_memory (50);
-          if (mainClassJar == NULL)
+          *mainClassJar = hymem_allocate_memory (sizeof(HARMONY_JARRUNNER_CLASSNAME) + 1);
+          if (*mainClassJar == NULL)
             {
               /* HYNLS_EXELIB_INTERNAL_VM_ERR_OUT_OF_MEMORY=Internal VM error: Out of memory\n
*/
               PORTLIB->nls_printf (PORTLIB, HYNLS_ERROR,
                                    HYNLS_EXELIB_INTERNAL_VM_ERR_OUT_OF_MEMORY);
               return 1;
             }
-          strcpy (mainClassJar, "org.apache.harmony.kernel.vm.JarRunner");
+          strcpy (*mainClassJar, HARMONY_JARRUNNER_CLASSNAME);
         }
     }
   /* entries from command line, properties file, 3 defaults plus the port library option
*/



Mime
View raw message